First, add the parameter to the array of options, but not to the validator, so it will throw an error:
$def_val = array(-1=>"--Select Countries--");
$sel_choices = array_merge($def_val,CountryPeer::getAllCountry());
sfWidgetFormChoice(array (
'choices' => $sel_choices,
))
sfValidatorChoice(array (
'choices' => array_keys(CountryPeer::getAllCountry()),
))
And then set the value to “-1” as the default value:
$your_form->setDefault('country', -1);
Must do it.
danii source
share