Is there any way or even work-around to cause the component to update from within the dependsOn function? Let's say for example that the field is using data from a relationship model that is also selectable on the same resource. Is there a way to do it?
BelongsTo::make('product'),
SimpleRepeatable::make('Varieties', [
Text::make('name),
Number::make('percentage'),
])
->dependsOn('product', function(SimpleRepeatable $field, NovaRequest $request, Form $formData) {
$product = Product::find($formData->product);
$field->setValue($product->varieties->map(fn($p) => $p->only(['name', 'percentage'])->toArray());
// Does not work :(
// I also tried the following but does not work either
$field->withMeta(['rows' => $product->varieties->map(fn($p) => $p->only(['name', 'percentage'])->toArray()]);
}),
Perhaps it's only there to conditionally display the field?
Is there any way or even work-around to cause the component to update from within the
dependsOn
function? Let's say for example that the field is using data from a relationship model that is also selectable on the same resource. Is there a way to do it?Perhaps it's only there to conditionally display the field?