ToggleColumn - making conditionally invisible
Hi I have the following code snippet
In the I can access $record - but within I am unable to (i.e. generates an error - "Attempt to read property "record_type" on null").
I don't understand why $record isn't universally available to me - but accepting that's the case, how would I access the current record within the method so that I can determine whether the toggle should be shown or not?
thanks for your help!
j
5 Replies
You can’t determine the visibility of a column by a row
try disabled instead
I guess that would explain why $record isn't available as that must only apply to rows - what I was hoping to achieve was that if a column on the underlying db table had value 'X' then the toggle will be shown; else it will be hidden. Is that achievable (perhaps through another method)?
Oh I see your reference to "disabled" as an alternative - I was hoping to hide it from view altogether (i.e. blank cell) on rows where it shouldn't be displayed.
Maybe you can get this to work via
->extraAttributes(fn ($record) => ['class' => 'class-that-targets-the-toggle'])
. Not sure whether that works with $record
but worth a tryThanks for the tip Dennis. I wonder if it's a useful feature to support natively (i.e. ability to programatically show/hide a toggle on a row-by-row basis) - is there a process by which I would propose this as an enhancement?
We have GitHub discussions for that. In general Editable Columns are quite basic and we don't see too many requests related to them