Welcome Guest, Not a member yet? Register   Sign In
form_dropdown and NULL value by default
#1

[eluser]tim1965[/eluser]
I have a form containing 10 optional rows. Each row contains a start and end date using form_dropdown for day, month, year. I want the form_dropdown to pass a default value of NULL to the database if the select is not set i.e. a blank value as the default value for the select. So that no value is inerted for the row. I have this working for all the other fields but cannot get this to work for the form_dropdown.
My view for the form dropdown looks like
<?php echo form_dropdown('start_day_1',$days,'D'); ?>
Where "D" is the initial default value
In the array i have tried to set the following values
'D'=>'NULL',
'D'=>'',
'D'=>' ',
'D'=>"",
'D'=>" ",
My database is set to apply a NULL by default
However none of these array options seem to work. Essentialy i want a blank value supplied if the user doesnt touch the select.
Any help appreciated
#2

[eluser]Evil Wizard[/eluser]
Its a string representation of the word 'NULL', maybe you should check after the post if the input contains 'NULL' and set the value to NULL before storing it in the database?
#3

[eluser]tim1965[/eluser]
Got it thanks

My validation was bombing the NULL value




Theme © iAndrew 2016 - Forum software by © MyBB