Alan
Edit when dependent drop down shows all values.
On edit when i change the product name the values in drop down has all values irrespective of manufacture until i change manufacture.How to sort this
if ($name === AllAttrib::ATTR_NAME_MANUFACTURER) {
$component = Select::make("itemAttrib.$attribId.value")
->label(__($name))
->options($taskAttrib['value'] ?? [])
->reactive()
->preload()
->live()
->afterStateUpdated(function (callable $get, callable $set) use ($attribId) {
$manufacturerId = $get("itemAttrib.$attribId.value");
$set("itemAttrib.product.value", null);
// Fetch product options based on selected manufacturer
$productOptions = AttribValue::where('parent_id', $manufacturerId)
->orderBy('value')
->pluck('value', 'id')
->toArray();
$set('productOptions', $productOptions);
})
->default($value);
} elseif ($name === AllAttrib::ATTR_NAME_PRODUCT_NAME) {
$component = Select::make("itemAttrib.$attribId.value")
->label(__($name))
->options(fn($get) => AttribValue::pluck('value', 'id')->toArray()) // Show all product options
->reactive()
->live()
->preload()
->default($value);
} else {
$component = Select::make("itemAttrib.$attribId.value")
->label(__($name))
->options($taskAttrib['value'] ?? [])
->default($value);
}
5 replies
Filament shield plugin not working?
I am using Filament Shield. While resources are correctly marked as forbidden based on permissions, How can I handle authorization for resources that share the same model name.Example my user resource and customer resource users user model when i restrict user resource for one role , i lose both the resources .
2 replies