F
Filament12mo ago
Xavi

Visible condition by relationship

I have this FieldSet
Fieldset::make(__('Enlaces en artículos ya publicados'))
->schema([
Grid::make()
->relationship('options')
->schema([
Checkbox::make('link_in_published')
->label(__('Quiero vender enlaces en artículos que ya esten publicados'))
->live(),
]),
Grid::make()
->relationship('prices')
->schema([
TextInput::make('cost_price_link_in_published')
->label(__('Precio por enlace'))
->visible(fn(Get $get) => $get('link_in_published'))
->required(),
]),
]),
Fieldset::make(__('Enlaces en artículos ya publicados'))
->schema([
Grid::make()
->relationship('options')
->schema([
Checkbox::make('link_in_published')
->label(__('Quiero vender enlaces en artículos que ya esten publicados'))
->live(),
]),
Grid::make()
->relationship('prices')
->schema([
TextInput::make('cost_price_link_in_published')
->label(__('Precio por enlace'))
->visible(fn(Get $get) => $get('link_in_published'))
->required(),
]),
]),
but cost_price_link_in_publisheddoesn't not make visible when i click on link_in_published. What i am doing wrong?
7 Replies
Xavi
XaviOP12mo ago
any one knows how to do this? I try a lot of things without results
HGalih
HGalih12mo ago
I have similar problem before but I cannot remember the fix. it has something to do with this piece of your code
fn(Get $get)
fn(Get $get)
I think i used something else other than $get and it definitely not Get type
Xavi
XaviOP12mo ago
thanks, but if i dd $get its an Filament\Forms\Get component. I think that it for relationship because if i dd $get('cost_price_link_in_published') it returns fine the value but $get('link_in_published') always returns null
awcodes
awcodes12mo ago
Try navigating the state. $get(‘../options/link_in_published’) something like that. The relationships add state paths Don’t remember if nested values use a dot or a /
Xavi
XaviOP12mo ago
thanks awcodes. I try with / and dot but it doesn't works i found it!. Solution its like this
$get('../options.link_in_published')
$get('../options.link_in_published')
awcodes
awcodes12mo ago
that's what i was referring to with the dot. 🙂
Xavi
XaviOP12mo ago
thank u so much!!!
Want results from more Discord servers?
Add your server