Change filament html element class definition dynamically
Hi. Check this SO post if possible: https://stackoverflow.com/questions/78803565/filament-add-extra-class-to-the-html-element-dynamically
I have a FileElement and I would like to add a class to it dynamically based on some properties. For example, take this piece of code:
What happens is that the extraAttributes method gets invoked when I change the FileUpload data in the form, however it does not update. It initially renders with the class that matches the logic, but if that changes, it does not add/remove any other classes. It's like the class property of the html element is only set during the first render, and any other changes to it are ignored. Is there anything I could do about it?
Stack Overflow
Filament add extra class to the html element dynamically
I have a FileElement and I would like to add a class to it dynamically based on some properties. For example, take this piece of code:
public static function makeImageFileUpload(
string $name,
...
5 Replies
TOP for this, seems to have been completely ignored
Isn't this the static value of maximal allowed files?
$component->getMaxFiles()
yes, getMaxFiles returns the maximum allowed files. Based on that, I want to show/hide some label within the component. The issue is that the
class
property does not get updated when I make changes such as uploading/delete a new file. The method gets called, I logged that, but the class
does not get updated$fileCount
never changes. It's a static value.
Ah count($get($name))
does. Overlooked it
I guess it might be, that some part of the component is wire:ingore
d and therefore some parts never update. Not sure though. It logs different values ("visible"/"hidden") on upload, right?Yes, the values logged are correct and what I would expect