Use Model->unbindModel() to unbind models dynamically
Refer the below links for more details
Question
I create some relations Model_One hasMany Model_Two
.
I create some form with Model_One
fields and a three fields likes Model_Two.0.name
, Model_Two.1.name
, Model_Two.2.name
.
In beforeSave
or beforeValidate
(no matter) of Model_2
I would like remove relations when name
it's empty. How to do this?
After saving my results should look like this:
Saved fields from Model_One
Saved fields from Model_Two
with keys, for example 0 and 2 (because Model_Two.1.name
was empty).
Solution
Use Model->unbindModel() to unbind models dynamically
Refer the below links for more details