my form set load values database (which i've passed via template engine) on first load, , posted values on subsequent loads if validation fails. instance, things work fine:
$title = array( 'name' => 'aboutme', 'id' => 'aboutme', 'value' => set_value('aboutme','{about_me}'), 'rows' => '20', 'cols' => '64' );
but i'm stumbling on form_dropdown.
$ethnicity_array = array('please choose', 'asian', 'black', 'hispanic / latin', 'native american', 'pacific islander', 'southeast asian', 'white', 'mixed', 'other'); echo form_dropdown('ethnicity', $ethnicity_array,set_value('ethnicity','{ethnicity}'));
it doesn't generate html mark choice selected.
even fails:
$var = set_value('ethnicity','{ethnicity}'); echo $var; // verify has expected value, let's 7 echo form_dropdown('ethnicity', $ethnicity_array,$var);
this fails -- is, doesn't generate proper html mark corresponding option selected:
echo form_dropdown('ethnicity',$ethnicity_array,(isset($_post['ethnicity']) ? $_post['ethnicity'] : $var));
but, works:
echo form_dropdown('ethnicity', $ethnicity_array,7);
and this:
$var = 7; echo form_dropdown('ethnicity', $ethnicity_array,$var);
it seems it's sort of type casting issue, maybe it's fundamentally don't understand php.
update: may typecasting issue. trying this:
$var = "{ethnicity}"; echo var_dump($var); $iv = intval($var); echo "<div>iv:</div>"; echo var_dump($iv);
yields:
string(15) "7" iv: int(0)
i have no clue why intval() return 0 string "7". i've looked @ other questions intval() here on stackoverflow , i'm more confused. if form_dropdown trying int conversion , it's failing, might problem.
you have pass set_value
third paramenter code should this
echo form_dropdown('ethnicity', $ethnicity_array, set_value('ethnicity'));
Comments
Post a Comment