is there a way to pass a value for an empty option in the dropdown list generated by FormHelper?
I create an input like this:
echo $this->Form->input('supplier_id', array('empty'=>true));
with values automatically added from the controller
$suppliers = $this->Product->Supplier->find('list'); $this->set(compact('suppliers'));
and the selection field is created as follows:
<select name="data[Product][supplier_id]" class="form-control" id="ProductSupplierId"> <option value=""></option> <option value="1">Lolë Montreal</option> <option value="2">Spiritual Gangster</option> <option value="3">Havaianas</option> </select>
but I would like the first option (empty) to have a value of 0 instead of ``, is this possible? or should I change the $suppliers array in the controller with something like
$suppliers[0] = '';
and remove the empty option from FormHelper input?
source share