This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I have 2 fields in my form:
1 - Many-to-Many Relation controller (list)
2 - Field of partial type.
Field #2 depends on list #1. How can I regenerate field #2 after list #1 is updated?
Last updated
My solution is to extend RelationController methods and add extra data to ajax framework response:
public function onRelationManagePivotCreate() {
$result = $this->asExtension('RelationController')->onRelationManagePivotCreate();
$result['#Form-field-MagazineSet-covers-group'] = $this->makePartial('form_covers', ['model' => $this->formGetModel()]);
return $result;
}
public function onRelationButtonRemove() {
$result = $this->asExtension('RelationController')->onRelationButtonRemove();
$result['#Form-field-MagazineSet-covers-group'] = $this->makePartial('form_covers', ['model' => $this->formGetModel()]);
return $result;
}
In my case I have many-to-many relation with pivot data. The 'slave' field (field #2 from my question) - is covers
and it's rendered by partial _from_covers.htm
. The name of the model is MagazineSet
.
The only problem with this solution is that you have to remove label
attribute from the field definition and add the html code of the label directly to your partial if you need (in my case I don't need label at all).
Last updated
1-2 of 2