Thanks Lorenzo, I already had read Mass Assignment 
<http://book.cakephp.org/3.0/en/orm/entities.html#entities-mass-assignment>on 
the book!

bake write:
    protected $_accessible = [
        'article' => true,
        'tag' => true,
    ];

should be:
    protected $_accessible = [
        '*' => true,
    ];

or:
    protected $_accessible = [
        'article' => true,
        'tag' => true,
        'article_id' => true,
        'tag' => true,
    ];



On Friday, April 17, 2015 at 4:03:52 AM UTC-3, José Lorenzo wrote:
>
> Pass ['accessibleFields' => ['*' => true]]; to your newEntity method. You 
> are hitting mass assignment prevention
>
> On Friday, April 17, 2015 at 8:58:22 AM UTC+2, [email protected] wrote:
>>
>> When I try to load data into a migration I get the following error 
>> message:
>>
>> [RuntimeException]                                                       
>>     
>>   Cannot insert row, some of the primary key values are missing. Got (, 
>> ), ex  
>>   pecting (article_id, tag_id)
>>
>> from this code:
>>
>> <?php
>> use Cake\ORM\TableRegistry;
>> use Phinx\Migration\AbstractMigration;
>>
>> class SeedMigration extends AbstractMigration
>> {
>>     public function change()
>>     {
>>        $this->table('articles_tags', ['id' => false, 'primary_key' => [
>> 'article_id', 'tag_id']])
>>             ->addColumn('article_id', 'integer')
>>             ->addForeignKey('article_id', 'articles', 'id')
>>             ->addColumn('tag_id', 'integer')
>>             ->addForeignKey('tag_id', 'tags', 'id')
>>             ->save();
>>        $articlesTags = TableRegistry::get('ArticlesTags');
>>             $articleTag = [
>>                 'article_id' => 1,
>>                 'tag_id' => 1,
>>             ];
>>        $articlesTags->save($articlesTags->newEntity($articleTag));
>>     }
>> }
>>
>> NOTE: Articles and Tags are created before and there are data with id 1
>>
>> regards --cesar
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to