Wednesday, November 3, 2010

Re: Basic issue with HABTM

On Tue, Nov 2, 2010 at 8:47 PM, Fernando Barrocal <fbarrocal@gmail.com> wrote:
> Some updates on here (paste bins are used to delete my post even when I ask
> to mantain)
> /* Tables /*
> users              people           contacts
> ---------- 1<--->1 -------- n<--->n ----------
> id                 id               id
> username           user_id          phone
>                    f_name
> Yes, there is a people_contacts table with both Ids
> /* View */
> <?php
> echo $this->Form->create('User');
> echo $this->Form->input('username');
> echo $this->Form->input('Person.f_name');
> echo $this->Form->input('Contact.0.phone');
> echo $this->Form->end(__('Submit', true));
> ?>
> /* Controller */
> function register($step = "create_account") {
>   if (!empty($this->data)) {
>     $this->User->create();
>     if ($this->User->saveAll($this->data)) {
>       $this->Session->setFlash(__('The user has been saved', true));
>     } else {
>       $this->Session->setFlash(__('The user could not be saved.', true));
>     }
>   }
> }
>
> On Tue, Nov 2, 2010 at 22:15, Fernando Barrocal <fbarrocal@gmail.com> wrote:
>>
>> Hi guys,
>> I am having some trouble with pretty basic things but it took me precious
>> hours today, and I decided to ask for some light ...
>> I have this config that I am trying to make work:
>> http://bin.cakephp.org/view/2004163346
>> I baked everything with cake bake and I need a way to proper save all 3
>> models on submit
>>
>> Any hints or ideas ?
>>
>> --
>> Fernando Barrocal <fbarrocal@gmail.com>
>> +55 11 8257-7200
>> +55 11 3020-7332
>> skype: fbarrocal
>
>
>
> --
> Fernando Barrocal <fbarrocal@gmail.com>
> +55 11 8257-7200
> +55 11 3020-7332
> skype: fbarrocal
>
> 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 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
>


I would save User first, then People/Contact, as you need to get the
user_id for People.

(shouldn't that be Person?)

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 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: