and last but not least
if you want to set default values - this is NOT done in the views
many make that mistake

this is actually done in the controller

if (!empty($this->data)) {
...
} else {
 // set default values here
$this->data['Model']['field'] = 'defautlValue';
}

this way after a post and some validation errors the defaults dont
override any chances

otherwise they would always jump back to default - which is really
annoying for users


On 15 Jun., 19:25, calvin <[email protected]> wrote:
> And also, if you have a nonstandard display field that isn't just
> being used for this particular select input, then you will probably
> want to set the $displayField property in your model so cake can
> automagically display that field in find('list') results and in
> tables.
>
> On Jun 15, 8:46 am, euromark <[email protected]> wrote:
>
>
>
> > usually you dont pass the dummy field via controller
> > there is an empty field param for it
>
> > echo $this->Form->input('category_id', array('options'=>$cats,
> > 'empty=>'dummyName');
> > or
> > echo $this->Form->input('category_id', array('options'=>$cats,
> > 'empty=>array('dummyFieldValue'=>'dummyName')));
>
> > On 15 Jun., 17:35, leo <[email protected]> wrote:
>
> > > You might also want to do this if you want to specify which fields to
> > > return:
> > > $this->set('categories', $this->Item->Category-
>
> > > >find('list',array('fields'=>array('id','other_name'));
>
> > > If you need to add a dummy field, try:
> > > $categories = array(0=>'unassigned') + 
> > > $this->Item->Category->find('list',array('fields'=>array('id','other_name')
> > >  );
>
> > > $this->set('categories', $categories);
>
> > > And in the view, if your categories aren't appearing (because the
> > > naming is different) try:
> > > echo $this->Form->input('category_id',array('options'=>$cats));

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