diff --git a/en/orm/saving-data.rst b/en/orm/saving-data.rst index 55ab8c5def..6b385264b9 100644 --- a/en/orm/saving-data.rst +++ b/en/orm/saving-data.rst @@ -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::