This is the dropdown code iam used:
$task_id = 2;
$inr = 0;
$arr = array();
foreach ($options as $option){
$inr = $option['Employee']['employee_id'];
$arr[$inr] = $option['Employee']['first_name'].' '.$option['Employee']['last_name'];
}
echo $this->Form->input('assigned_to', array( 'options' => array( $arr),
'empty' => '(choose one)',
'div'=>'formfield',
'label' => 'Assigned To',
'error' => array( 'wrap' => 'div',
'class' => 'formerror'
)
));
Its displayed with correct values in the $options.
But i need to select one option value usinsg cakephp code.
How can i do this?
That is i have a variable with value as :
$task_id = 2;
So how can i put selection to this option value?
If it is possible ?
you mean default value?
either use
defaultkey in the attributes for your form input element or the cleaner approach using the controller:@see http://www.dereuromark.de/2010/06/23/working-with-forms/