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?

4
  • can you please show your code? Commented Dec 9, 2015 at 0:42
  • This might help - book.cakephp.org/3.0/en/orm/… Commented Dec 9, 2015 at 10:57
  • @manetsus my code is same as in the tutorilal Commented Dec 11, 2015 at 0: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) Commented Dec 11, 2015 at 0:20

1 Answer 1

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');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.