Thursday, September 25, 2008

Re: Problem with form helper

what happens when you do it the other way . . .

in controller . . .. . . .
$contacts = $this->Contact->find('all', array(
'conditions' => array(
'Contact.user_id' => $this->Session->read('Auth.User.id')
));
$this->set('contacts', $contacts);

in view . . . .
foreach($contacts as $contact) {
echo $form->input($contact['Contact']['name']);
}

this is the way I usually do this type of view setup . .. i don't use
array integers

i may be off on this, so somebody more cakephp involved, could help
you

On Sep 25, 9:50 am, Günther Theilen <thei...@eqi.de> wrote:
> I want to edit multiple records in one view.
>
> Controller:
>
> $this->data = $this->Contact->find('all', array(
>    'conditions' => array(
>      'Contact.user_id' => $this->Session->read('Auth.User.id')
> ));
>
> View (simplified):
>
> for ($i = 0; $i < count($this->data); $i++):
> e($form->input("$i.Contact.name");
>
> Which works perfectly for the second, third,... records but not for the
> first which has the array key 0.
>
> Donkeybob schrieb:
>
> > Why would you be using an array integer instead of the model name?
> > Does this not use a model? Code you post you controller code that
> > populates this form?
>
> > On Sep 25, 8:54 am, Günther Theilen <thei...@eqi.de> wrote:
> >> Hi!
>
> >> I've got a weird problem with the form helper, maybe someone can help...
>
> >> $form->input("5.name") creates an input field with name="data[5][name]",
> >> which is pretty much what I expected.
>
> >> But $form->input("0.name") creates an input field with
> >> name="data[foo][name]", foo is the pluralized modelname.
>
> >> Why?
> >> And how can I create an input field with name="data[0][name]"?
> >> (Except for creating it manually of course... ;-))
> >> (Cake 1.2.0.7296 RC2)
>
> >> Regards
> >> Guenther
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: