Hey guys

I'm creating a form using the Form helper, and I'd like to send
default values using named params:

/users/add/first_name:max/last_name:miller

I've already come so far that the input() accepts default values for
text fields and dropdown lists:

echo $this->Form->create(null, array('url' => '/'.$this->params['url']
['url']));
foreach($scaffoldFields as $field) {
  $selected = null;
  if(empty($this->data) && isset($this->params['named'][$field])) { //
When there's no data present (sent using POST or loaded from the
database), then apply any default values from named parameters!
    $selected = $this->params['named'][$field];
  }
  echo $this->Form->input($field, array('selected' => $selected,
'default' => $selected)); // TODO: Not very nice to have both selected
(dropdown) and default (text) keys here...!
}
echo $this->Form->end(__('Submit', true));

But I'm unsure on how to implement this for checkboxes and multi
select lists? For this I'd have to know what sort of field the helper
creates, and then e.g. I could send an array of values as default.

Is there an easy way to examine what sort of input field will be
created by the Form helper?

Thanks,
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to