Replies: 4 comments 1 reply
-
@mjauvin would you be able to take a look? |
Beta Was this translation helpful? Give feedback.
-
@goldmont if you could submit a PR to the Winter.Test plugin's User/UserRolePivot models to demonstrate this, that would help move this forward for investigation. Thanks. |
Beta Was this translation helpful? Give feedback.
-
@goldmont you cannot use the Pivot Model for filterFields, use |
Beta Was this translation helpful? Give feedback.
-
Hi, As you said, I've managed to alter pivot form using I had to dynamically access the field using the following syntax: public function filterFields($fields, $context = null)
{
$fields->{'pivot[my_field]'}->hidden = true;
} By the way, I'm still unable to get the value of a dropdown |
Beta Was this translation helpful? Give feedback.
-
Winter CMS Build
dev-develop
PHP Version
8.1
Database engine
MySQL/MariaDB
Plugins installed
None
Issue description
Hi there.
I have the following scenario:
I have many
Devices
that could be related to manyDashboards
. Thepivot
table has also additional attributes set via apivot
form. There is apivotModel
that extendsWinter\Storm\Database\Pivot
. From theDashboard
form, I can link many devices and, every time I choose a device, thepivot
form is displayed to allow me to enterpivot
additional attributes.I'm trying to manipulate
pivot
form viafilterFields
method but I noticed that this last not called onpivotModel
but onDevice::class
. FromDevice::class
I'm unable to accesspivot
form fields. HoweverAccessors
andMutators
are correctly called onpivotModel
.Steps to replicate
Dashboard
model:I tried to implement
relationExtendPivotWidget($widget, $field, $model)
method into theDashboards
controller and I'm able to manipulate thepivot
form. By the way$widget->model->pivot
data is an empty array unless thecontext
isupdate
.Like this:
Workaround
I've also noticed that if I call manually the method
$widget->getSaveData()
insiderelationExtendPivotWidget($widget, $field, $model)
I can getpivot
form data sent via AJAX request.Like this:
By the way, for some reason, after calling
$widget->getSaveData();
, the line$widget->fields['pivot[my_field]']['hidden'] = true;
has no effect.Beta Was this translation helpful? Give feedback.
All reactions