Re: Form: hasMany fields table validation not working

2016-02-29 Thread Paulo Terra
Ok, thank you very much! I am sorry that I didn't realize this singular and
plural detail.

Thank you very much!

Paulo

2016-02-29 11:36 GMT-03:00 Dakota :

> Not a problem, glad that worked for you.
>
> For future reference, you can usually get nearly instant help on the IRC
> channel (
> http://webchat.freenode.net/?channels=cakephp&uio=MT1mYWxzZSY5PXRydWUmMTE9MjQ2b8),
> depending on who is online of course. Stackoverflow is also usually more
> active than the group.
>
> On Monday, 29 February 2016 16:31:11 UTC+2, Paulo Terra wrote:
>>
>> Great! It Works! Thank you Dakota!
>>
>> 2016-02-29 11:15 GMT-03:00 Dakota :
>>
>>> Hi Paulo,
>>>
>>> Your form field for address zipcode field is in the wrong format.
>>> http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-inputs-for-associated-data
>>> shows the correct format for each type of relation. Basically, instead of
>>> doing
>>> $this->Form->input('address.zipcode');
>>>
>>> You need to do instead do:
>>> $this->Form->input('addresses.0.zipcode');
>>>
>>> For hasMany relations, the key is always plural and you need to specify
>>> a numeric index.
>>>
>>>
>>>
>>> On Sunday, 28 February 2016 22:07:32 UTC+2, Paulo Terra wrote:

 Hi,

 I have 3 tables: User, Buyer and Address:

 User hasMany Address
 User hasOne Buyer
 Address belongsTo User
 Buyer belongsTo User

 In the User form (Users/add.ctp):

 echo $this->Form->input('name',['label' => __('Nome')]);
 echo $this->Form->input('buyer.cpf',['label' => __('CPF')]);
 echo $this->Form->input('address.zipcode');



 UsersTable.php:

 $this->hasMany('Addresses', [
 'foreignKey' => 'user_id'
 ]);

 $this->hasOne('Buyers', [
 'foreignKey' => 'user_id'
 ]);



 BuyersTable.php:

 $this->table('buyers');
 $this->displayField('id');
 $this->primaryKey('id');
 $this->belongsTo('Users', [
 'foreignKey' => 'user_id',
 'joinType' => 'INNER'
 ]);


 AddressTable.php:

 $this->table('addresses');
 $this->displayField('id');
 $this->primaryKey('id');
 $this->belongsTo('Users', [
 'foreignKey' => 'user_id',
 'joinType' => 'INNER'
 ]);



 The field "cpf" from Buyer is recognized by cake as it´s Model is shown
 in the include path:


- *Model*(array)
   - *0*APP/Model/Table/UsersTable.php
   - *1*APP/Model/Entity/User.php
   - *2*APP/Model/Table/SurveysTable.php
   - *3*APP/Model/Table/BuyersTable.php
   - *4*APP/Model/Entity/Buyer.php
   - *5*APP/Model/Entity/Survey.php

 And "cpf" is also a "not null" field, whitch is properly verifyed in
 cake when I save.

 The problem is the "zipcode" field in "Address". It´s is also a
 required field but it is not validated from cake. And, as can be seen, it
 is not loaded in Model list.

 But when I change the relation Address relation from "hasMany" to
 "hasOne" it works (it also validade required field when I save).


 UsersTable.php:

 $this->hasOne('Addresses', [
 'foreignKey' => 'user_id'
 ]);

 $this->hasOne('Buyers', [
 'foreignKey' => 'user_id'
 ]);



- *Model*(array)
   - *0*APP/Model/Table/UsersTable.php
   - *1*APP/Model/Entity/User.php
   - *2*APP/Model/Table/SurveysTable.php
   - *3*APP/Model/Table/BuyersTable.php
   - *4*APP/Model/Entity/Buyer.php
   - *5*APP/Model/Table/AddressesTable.php
   - *6*APP/Model/Entity/Address.php
   - *7*APP/Model/Entity/Survey.php



 Does anyone has a clue about what is happening?

 --
>>> Sign up for our Newsletter for updates.
>>> http://cakephp.org/newsletter/signup
>>>
>>> We will soon be closing this Google Group. But don't worry, we have
>>> something better coming. Stay tuned for an updated from the CakePHP Team
>>> soon.
>>>
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Follow us on Twitter http://twitter.com/CakePHP
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "CakePHP" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/cake-php/M8MwE8p8SZc/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> cake-php+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Sign up for our Newsletter for updates.
> http://cakephp.org/newsletter/signup
>
> We will soon be closing this Google Group. But don't worry, we have
> something better coming. S

Re: Form: hasMany fields table validation not working

2016-02-29 Thread Dakota
Not a problem, glad that worked for you.

For future reference, you can usually get nearly instant help on the IRC 
channel 
(http://webchat.freenode.net/?channels=cakephp&uio=MT1mYWxzZSY5PXRydWUmMTE9MjQ2b8),
 
depending on who is online of course. Stackoverflow is also usually more 
active than the group.

On Monday, 29 February 2016 16:31:11 UTC+2, Paulo Terra wrote:
>
> Great! It Works! Thank you Dakota!
>
> 2016-02-29 11:15 GMT-03:00 Dakota >:
>
>> Hi Paulo,
>>
>> Your form field for address zipcode field is in the wrong format. 
>> http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-inputs-for-associated-data
>>  
>> shows the correct format for each type of relation. Basically, instead of 
>> doing 
>> $this->Form->input('address.zipcode');
>>
>> You need to do instead do:
>> $this->Form->input('addresses.0.zipcode');
>>
>> For hasMany relations, the key is always plural and you need to specify a 
>> numeric index.
>>
>>
>>
>> On Sunday, 28 February 2016 22:07:32 UTC+2, Paulo Terra wrote:
>>>
>>> Hi,
>>>
>>> I have 3 tables: User, Buyer and Address:
>>>
>>> User hasMany Address
>>> User hasOne Buyer
>>> Address belongsTo User
>>> Buyer belongsTo User
>>>
>>> In the User form (Users/add.ctp):
>>>
>>> echo $this->Form->input('name',['label' => __('Nome')]);
>>> echo $this->Form->input('buyer.cpf',['label' => __('CPF')]);
>>> echo $this->Form->input('address.zipcode');
>>>
>>>
>>>
>>> UsersTable.php:
>>>
>>> $this->hasMany('Addresses', [
>>> 'foreignKey' => 'user_id'
>>> ]);
>>> 
>>> $this->hasOne('Buyers', [
>>> 'foreignKey' => 'user_id'
>>> ]);
>>>
>>>
>>>
>>> BuyersTable.php:
>>>
>>> $this->table('buyers');
>>> $this->displayField('id');
>>> $this->primaryKey('id');
>>> $this->belongsTo('Users', [
>>> 'foreignKey' => 'user_id',
>>> 'joinType' => 'INNER'
>>> ]);
>>>
>>>
>>> AddressTable.php:
>>>
>>> $this->table('addresses');
>>> $this->displayField('id');
>>> $this->primaryKey('id');
>>> $this->belongsTo('Users', [
>>> 'foreignKey' => 'user_id',
>>> 'joinType' => 'INNER'
>>> ]);
>>>
>>>
>>>
>>> The field "cpf" from Buyer is recognized by cake as it´s Model is shown 
>>> in the include path:
>>>
>>>
>>>- *Model*(array)
>>>   - *0*APP/Model/Table/UsersTable.php
>>>   - *1*APP/Model/Entity/User.php
>>>   - *2*APP/Model/Table/SurveysTable.php
>>>   - *3*APP/Model/Table/BuyersTable.php
>>>   - *4*APP/Model/Entity/Buyer.php
>>>   - *5*APP/Model/Entity/Survey.php
>>>
>>> And "cpf" is also a "not null" field, whitch is properly verifyed in 
>>> cake when I save.
>>>
>>> The problem is the "zipcode" field in "Address". It´s is also a required 
>>> field but it is not validated from cake. And, as can be seen, it is not 
>>> loaded in Model list.
>>>
>>> But when I change the relation Address relation from "hasMany" to 
>>> "hasOne" it works (it also validade required field when I save).
>>>
>>>
>>> UsersTable.php:
>>>
>>> $this->hasOne('Addresses', [
>>> 'foreignKey' => 'user_id'
>>> ]);
>>> 
>>> $this->hasOne('Buyers', [
>>> 'foreignKey' => 'user_id'
>>> ]);
>>>
>>>
>>>
>>>- *Model*(array)
>>>   - *0*APP/Model/Table/UsersTable.php
>>>   - *1*APP/Model/Entity/User.php
>>>   - *2*APP/Model/Table/SurveysTable.php
>>>   - *3*APP/Model/Table/BuyersTable.php
>>>   - *4*APP/Model/Entity/Buyer.php
>>>   - *5*APP/Model/Table/AddressesTable.php
>>>   - *6*APP/Model/Entity/Address.php
>>>   - *7*APP/Model/Entity/Survey.php
>>>
>>>
>>>
>>> Does anyone has a clue about what is happening?
>>>
>>> -- 
>> Sign up for our Newsletter for updates.
>> http://cakephp.org/newsletter/signup
>>  
>> We will soon be closing this Google Group. But don't worry, we have 
>> something better coming. Stay tuned for an updated from the CakePHP Team 
>> soon.
>>  
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Follow us on Twitter http://twitter.com/CakePHP
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "CakePHP" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/cake-php/M8MwE8p8SZc/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> cake-php+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup

We will soon be closing this Google Group. But don't worry, we have something 
better coming. Stay tuned for an updated from the CakePHP Team soon.

Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe f

Re: Form: hasMany fields table validation not working

2016-02-29 Thread Paulo Terra
Great! It Works! Thank you Dakota!

2016-02-29 11:15 GMT-03:00 Dakota :

> Hi Paulo,
>
> Your form field for address zipcode field is in the wrong format.
> http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-inputs-for-associated-data
> shows the correct format for each type of relation. Basically, instead of
> doing
> $this->Form->input('address.zipcode');
>
> You need to do instead do:
> $this->Form->input('addresses.0.zipcode');
>
> For hasMany relations, the key is always plural and you need to specify a
> numeric index.
>
>
>
> On Sunday, 28 February 2016 22:07:32 UTC+2, Paulo Terra wrote:
>>
>> Hi,
>>
>> I have 3 tables: User, Buyer and Address:
>>
>> User hasMany Address
>> User hasOne Buyer
>> Address belongsTo User
>> Buyer belongsTo User
>>
>> In the User form (Users/add.ctp):
>>
>> echo $this->Form->input('name',['label' => __('Nome')]);
>> echo $this->Form->input('buyer.cpf',['label' => __('CPF')]);
>> echo $this->Form->input('address.zipcode');
>>
>>
>>
>> UsersTable.php:
>>
>> $this->hasMany('Addresses', [
>> 'foreignKey' => 'user_id'
>> ]);
>>
>> $this->hasOne('Buyers', [
>> 'foreignKey' => 'user_id'
>> ]);
>>
>>
>>
>> BuyersTable.php:
>>
>> $this->table('buyers');
>> $this->displayField('id');
>> $this->primaryKey('id');
>> $this->belongsTo('Users', [
>> 'foreignKey' => 'user_id',
>> 'joinType' => 'INNER'
>> ]);
>>
>>
>> AddressTable.php:
>>
>> $this->table('addresses');
>> $this->displayField('id');
>> $this->primaryKey('id');
>> $this->belongsTo('Users', [
>> 'foreignKey' => 'user_id',
>> 'joinType' => 'INNER'
>> ]);
>>
>>
>>
>> The field "cpf" from Buyer is recognized by cake as it´s Model is shown
>> in the include path:
>>
>>
>>- *Model*(array)
>>   - *0*APP/Model/Table/UsersTable.php
>>   - *1*APP/Model/Entity/User.php
>>   - *2*APP/Model/Table/SurveysTable.php
>>   - *3*APP/Model/Table/BuyersTable.php
>>   - *4*APP/Model/Entity/Buyer.php
>>   - *5*APP/Model/Entity/Survey.php
>>
>> And "cpf" is also a "not null" field, whitch is properly verifyed in cake
>> when I save.
>>
>> The problem is the "zipcode" field in "Address". It´s is also a required
>> field but it is not validated from cake. And, as can be seen, it is not
>> loaded in Model list.
>>
>> But when I change the relation Address relation from "hasMany" to
>> "hasOne" it works (it also validade required field when I save).
>>
>>
>> UsersTable.php:
>>
>> $this->hasOne('Addresses', [
>> 'foreignKey' => 'user_id'
>> ]);
>>
>> $this->hasOne('Buyers', [
>> 'foreignKey' => 'user_id'
>> ]);
>>
>>
>>
>>- *Model*(array)
>>   - *0*APP/Model/Table/UsersTable.php
>>   - *1*APP/Model/Entity/User.php
>>   - *2*APP/Model/Table/SurveysTable.php
>>   - *3*APP/Model/Table/BuyersTable.php
>>   - *4*APP/Model/Entity/Buyer.php
>>   - *5*APP/Model/Table/AddressesTable.php
>>   - *6*APP/Model/Entity/Address.php
>>   - *7*APP/Model/Entity/Survey.php
>>
>>
>>
>> Does anyone has a clue about what is happening?
>>
>> --
> Sign up for our Newsletter for updates.
> http://cakephp.org/newsletter/signup
>
> We will soon be closing this Google Group. But don't worry, we have
> something better coming. Stay tuned for an updated from the CakePHP Team
> soon.
>
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Follow us on Twitter http://twitter.com/CakePHP
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/M8MwE8p8SZc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup

We will soon be closing this Google Group. But don't worry, we have something 
better coming. Stay tuned for an updated from the CakePHP Team soon.

Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form: hasMany fields table validation not working

2016-02-29 Thread Dakota
Hi Paulo,

Your form field for address zipcode field is in the wrong 
format. 
http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-inputs-for-associated-data
 
shows the correct format for each type of relation. Basically, instead of 
doing 
$this->Form->input('address.zipcode');

You need to do instead do:
$this->Form->input('addresses.0.zipcode');

For hasMany relations, the key is always plural and you need to specify a 
numeric index.


On Sunday, 28 February 2016 22:07:32 UTC+2, Paulo Terra wrote:
>
> Hi,
>
> I have 3 tables: User, Buyer and Address:
>
> User hasMany Address
> User hasOne Buyer
> Address belongsTo User
> Buyer belongsTo User
>
> In the User form (Users/add.ctp):
>
> echo $this->Form->input('name',['label' => __('Nome')]);
> echo $this->Form->input('buyer.cpf',['label' => __('CPF')]);
> echo $this->Form->input('address.zipcode');
>
>
>
> UsersTable.php:
>
> $this->hasMany('Addresses', [
> 'foreignKey' => 'user_id'
> ]);
> 
> $this->hasOne('Buyers', [
> 'foreignKey' => 'user_id'
> ]);
>
>
>
> BuyersTable.php:
>
> $this->table('buyers');
> $this->displayField('id');
> $this->primaryKey('id');
> $this->belongsTo('Users', [
> 'foreignKey' => 'user_id',
> 'joinType' => 'INNER'
> ]);
>
>
> AddressTable.php:
>
> $this->table('addresses');
> $this->displayField('id');
> $this->primaryKey('id');
> $this->belongsTo('Users', [
> 'foreignKey' => 'user_id',
> 'joinType' => 'INNER'
> ]);
>
>
>
> The field "cpf" from Buyer is recognized by cake as it´s Model is shown in 
> the include path:
>
>
>- *Model*(array)
>   - *0*APP/Model/Table/UsersTable.php
>   - *1*APP/Model/Entity/User.php
>   - *2*APP/Model/Table/SurveysTable.php
>   - *3*APP/Model/Table/BuyersTable.php
>   - *4*APP/Model/Entity/Buyer.php
>   - *5*APP/Model/Entity/Survey.php
>
> And "cpf" is also a "not null" field, whitch is properly verifyed in cake 
> when I save.
>
> The problem is the "zipcode" field in "Address". It´s is also a required 
> field but it is not validated from cake. And, as can be seen, it is not 
> loaded in Model list.
>
> But when I change the relation Address relation from "hasMany" to "hasOne" 
> it works (it also validade required field when I save).
>
>
> UsersTable.php:
>
> $this->hasOne('Addresses', [
> 'foreignKey' => 'user_id'
> ]);
> 
> $this->hasOne('Buyers', [
> 'foreignKey' => 'user_id'
> ]);
>
>
>
>- *Model*(array)
>   - *0*APP/Model/Table/UsersTable.php
>   - *1*APP/Model/Entity/User.php
>   - *2*APP/Model/Table/SurveysTable.php
>   - *3*APP/Model/Table/BuyersTable.php
>   - *4*APP/Model/Entity/Buyer.php
>   - *5*APP/Model/Table/AddressesTable.php
>   - *6*APP/Model/Entity/Address.php
>   - *7*APP/Model/Entity/Survey.php
>
>
>
> Does anyone has a clue about what is happening?
>
>

-- 
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup

We will soon be closing this Google Group. But don't worry, we have something 
better coming. Stay tuned for an updated from the CakePHP Team soon.

Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.