To make a dafault value of select in my form I do like that :
$def_volume = array(-1=>"Please select a volume");
$def_issue = array(-1=>"Please select issue");
$volumes = array_merge($def_volume,IssuePeer::getAllVolumesForListChoices());
$issues = array_merge($def_issue,IssuePeer::getAllIssuesForListChoices());
$this->setWidgets(array(
'keyword' => new sfWidgetFormInput(),
'volume' => new sfWidgetFormSelect(array('choices' => $volumes)),
'issue' => new sfWidgetFormSelect(array('choices' => $issues)),
));
$this->setValidators(array(
'keyword' => new sfValidatorString(array('required' => true)),
'volume' => new sfValidatorChoice(array('choices' => array_keys(IssuePeer::getAllVolumesForListChoices()))),
'issue' => new sfValidatorChoice(array('choices' => array_keys(IssuePeer::getAllIssuesForListChoices()))),
));
the output :
<select id="filterSearch_volume" name="filterSearch[volume]">
<option value="0">Please select a volume</option>
....
</select>
but I hope to have the output like this :
<select id="filterSearch_volume" name="filterSearch[volume]">
<option value="">Please select a volume</option>
....
</select>
If you remark the value of the first value is value="0"
but I hope that return me "null" like this value=""
.
Have you tried:
$def_volume = array('' => "Please select a volume");
That seems to work for me.