Description
Hey
I have a Post
model which can be of 2 types: regular
and poll
. A Post
model of type poll
will be related to a Poll
model in a 1-1 manner. Among all other attributes, a Poll
model has selection_mode
and max_selected_count
. With all of these said, here is my issue:
I'm using yassipad/laravel-nova-nested-form
to display create/update form of a Poll
model inside create/update form its related Post
. Also, I wrap max_selection_count
field of Poll
inside a ConditionalContainer
field to make it visible only if selection_mode
is equal to multiple
.
Everything works fine in isolation, but when it comes to max_selection_count
field inside the Post
create/update page, it does not work as expected. Inside Post
form and when type
is poll
, no matter what option I choose for selection_mode
, max_selection_count
will not appear.
Here is my code snippets:
// app/Nova/Post.php
public function fields(Request $request)
{
return [
// ...
Select::make('type')->options(['Regular' => 'regular', 'Poll' => 'poll']),
ConditionalContainer::make([
NestedForm::make('poll', Poll::class)
])->if('type = poll')
];
}
// app/Nova/Poll.php
public function fields(Request $request)
{
return [
// ...
Select::make('selection_mode')->options(['Single' => 'single', 'Multiple' => 'multiple']),
ConditionalContainer::make([
Number::make('max_selection_count')
])->if('selection_mode = multiple'),
];
}