Replies: 5 comments 9 replies
-
Example with reactive Select::make('Select')
->options([
1 => 1,
2 => 2,
])
->reactive(function (Fields $fields, mixed $value, Select $ctx, array $values) {
if($values['color'] === 'R') {
// change options - $ctx->options([]);
$ctx->setValue(2);
}
return $fields;
}),
Enum::make('Color')
->reactive()
->attach(ColorEnum::class)
, |
Beta Was this translation helpful? Give feedback.
-
Thanks lee-to,
Is it link to the fact i'm using BelongsTo and not passing a BelongsTo in my reactive function params? Thanks :) |
Beta Was this translation helpful? Give feedback.
-
Neither of these seem to work unfortunately. I tried Not sure why, but no logs pop up when i change my object value :
But does show up when i change my Belongsto values, and my object field is always null.
|
Beta Was this translation helpful? Give feedback.
-
The values of the BelongsTo field are Model collection, the selected value is also a Model object, not primitives as in the Select Also look at the asyncSearch method of the BelongsTo, you can change the searchQuery, inside there will be a request with all the form data, based on which you can change the builder |
Beta Was this translation helpful? Give feedback.
-
Ok so renaming does the trick! Thank you, i did not understand the phrase "Just use reactive.{column}" correctly On the xData however, need to pass object, not reactive.object : |
Beta Was this translation helpful? Give feedback.
-
Hi there!
I can't seem to find how to empty a field value when i change a Select value from another field.
Say i have my Select field "object", i wish to hide/show the fields associated to the value i choose.
The xShow works fine, but doesn't clear the value.
What is the best way to do this ?
I tried using reactive() like in the documentation, but I don't think i'm implementing it correctly. Or can i use the onChangeMethod() ?
Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions