Wednesday, April 4, 2012

Re: Problem in edit-view with data from a HABTM-relationship



Am Mittwoch, 4. April 2012 15:35:26 UTC+2 schrieb Mike Griffin:
On Wed, Apr 4, 2012 at 13:50, Wall-D <marco.walther@gmail.com> wrote:
> Yes, it should be the list of all detail-types with the correct one
> selected.
>
> in the controller I'm passing them to the view:
> '        $detail_types = $this->Device->Detail->DetailType->find('list',
> array('order' => 'DetailType.name ASC'));
>  and the label shows up the correct DetailType
>
> I tried many combinations, but nothing worked for me ...

echo $this->Form->input('Detail'.$counter.'DetailType'.'name', array(
                        'options' => $detail_types,
                        'label' => 'Detail Art ',
                        'selected' =>
$this->Form->data['Detail'][$counter].'detail_type_id',
                        'div'=>'formfield',
                        'error' => array(
                            'wrap' => 'div',
                            'class' => 'formerror'
                            )
                        ));

Note the options part of the array. Does that change anything?

Mike.


Wonderful,

fully working incl. selected option:

               echo $this->Form->input('Detail'.$counter.'DetailType'.'name', array(
                        'options' => $detail_types,
                        'label' => 'Detail Art ',
                        'selected' => $this->Form->data['Detail'][$counter]['detail_type_id'],
                        'div'=>'formfield',
                        'error' => array(
                            'wrap' => 'div',
                            'class' => 'formerror'
                            )
                        ));

Thanks a lot

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: