Skip to content

Commit

Permalink
Merge pull request #7659 from celsowm/patch-16
Browse files Browse the repository at this point in the history
Update saving-data.rst
  • Loading branch information
markstory authored Jul 25, 2023
2 parents 71c67bd + 18c15cb commit abd2aa1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions en/orm/saving-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,18 @@ by setting data to the ``_joinData`` property::

$studentsTable->save($student);

The example above will only work if the property ``_joinData`` is already a
reference to a Join Table Entity. If this is not your case you can populate
using the Table to create the entity::

$coursesMembershipsTable = $this->getTableLocator()->get('CoursesMemberships');
$student->courses[0]->_joinData = $coursesMembershipsTable->newEntity([
'grade' => 80.12,
'days_attended' => 30
]);

$studentsTable->save($student);

The ``_joinData`` property can be either an entity, or an array of data if you
are saving entities built from request data. When saving junction table data
from request data your POST data should look like::
Expand Down

0 comments on commit abd2aa1

Please sign in to comment.