select options
->visible((fn (Get $get): array => bool ($get('product_id')) {[4 => "test"]})
can someone help me in this code
11 Replies
What are you actually trying to achieve here?
Sorry our mind reading skills are not quite there right now, please provide context as per the #✅┊rules of what you want this code to do as right not, it's meaingless code.
i want make hide or visible a field and a select field
Under what condition? Your current callback makes no sense. Share more of the code and explain the circumstances that you want the field to be hidden under
Ok i will share with you code
Select::make('product_id')
->label('Product')
->options(function (callable $get){
$subcategorie = SubCategory::find($get('sub_category_id'));
if(!$subcategorie){
return Product::all()->pluck('name', 'id');
}
return $subcategorie->Product->pluck('name', 'id');
})
->required()
->preload()
->searchable()
->live()
->reactive()
->loadingMessage('Loading Produits...')
->noSearchResultsMessage('Pas de produit trouvé')
->placeholder('Sous Catégorie'),
TextInput::make('company_name') ->visible((fn (Get $get): array => bool ($get('product_id')) {[4 => "test"]}) thats my code
TextInput::make('company_name') ->visible((fn (Get $get): array => bool ($get('product_id')) {[4 => "test"]}) thats my code
So are you trying to hide the company_name field when product_id is 4?
When should company_name be hidden/visible
yes
right
but its select field and when i make value
return null
Then this will work, this will hide the company_name field when product_id is 4:
its works thank you so much but i need make name of product not the ID is it possible
really thank you for your help
Solution
thank you so much guys