From 827551832655f25cddb6bc5f9f56b573bf0b09aa Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 23 Jan 2025 10:13:39 -0500 Subject: [PATCH] Add docs for cakephp/cakephp#18136 --- en/appendices/5-2-migration-guide.rst | 4 ++++ en/orm/saving-data.rst | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index dad4e6a7b4..79877bdace 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -81,6 +81,10 @@ ORM - ``CounterCacheBehavior::updateCounterCache()`` has been addded. This method allows you to update the counter cache values for all records of the configured associations. +- ``BelongsToMany::setJunctionProperty()`` and ``getJunctionProperty()`` were + added. These methods allow you to customize the ``_joinData`` property that is + used to hydrate junction table records. + View ---- diff --git a/en/orm/saving-data.rst b/en/orm/saving-data.rst index c6145ec6c4..7067536e9c 100644 --- a/en/orm/saving-data.rst +++ b/en/orm/saving-data.rst @@ -1070,7 +1070,18 @@ from request data your POST data should look like:: ]); See the :ref:`associated-form-inputs` documentation for how to build inputs with -``FormHelper`` correctly. +``FormHelper`` correctly. As of 5.2.0, the ``_joinData`` property can be renamed +with ``setJunctionProperty()``:: + + // in StudentsTable::initialize() + $this->belongsToMany('Courses') + ->setJunctionProperty('course_mark'); + +When a junction property is set, the new junction property name must be used to +manipulate entities, marshall request data, and create form fields. + +.. versionadded:: 5.2.0 + Custom junction property names were added. .. _saving-complex-types: