0

While going through a cakephp 3 tutorial about bookmarks and tags I've struggled with a problem: I want to add the third field to the users_tags table (tag_type: important or not), but when it saves the data it rewrites previous values to the default database value of "tag_type".

Could you please help me figure out what I'm doing wrong?

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
Andrew
  • 13
  • 5
  • can you please show your code? – Enamul Hassan Dec 09 '15 at 00:42
  • This might help - http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-additional-data-to-the-joint-table – cjquinn Dec 09 '15 at 10:57
  • @manetsus my code is same as in the tutorilal – Andrew Dec 11 '15 at 00:15
  • @cjquinn Thanx, but i saw that, but can't understand how to use this in tutorial's case (when i update one part of tag's list - second part rewrites). So i want to split tags into 2 types for every user. And each user can change each list of his tags (important and not important tags). Help pls) – Andrew Dec 11 '15 at 00:20

1 Answers1

1

If you added the tag_type column to the users_tags table after running bake commands, check $_accessible array value in entity file of the table i.e. src/Model/Entity/UsersTag.php and add an element with column name as key and true as value to make sure column value can be mass assigned

In your Form html of user add/edit page, add an input like this so that cakephp matches its value with proper column automatically when you create an entity in your controller :

echo $this->Form->input('tags.0._joinData.tag_type');
Gaurav
  • 1,942
  • 19
  • 31