Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bernhardh's avatar

Nova Fields - run a method on all fields

Is there a way to run a method on all fields or to set a default meta attribute an all fields?

For example, I want to set ALL Fields as required (rules('required')) and hidden from index (hideFromIndex()) by default and only overwrite it for specific fields in the nova resource class.

Something like:

Field::boot(function($field){
    return $field->rules('required')->hideFromIndex();
});
0 likes
3 replies
bugsysha's avatar

Haven't seen anything like this. Maybe you can create some kind of wrappers for them or create you own Field which will extend Nova's Field and do same for other classes that extend Field like Text, Number and so on.

bernhardh's avatar

Create you own Field which will extend Nova's Field and do same for other classes that extend Field like Text, Number and so on

That was my first thought, but then I would need to extend every field of nova and all used packages by my own and keep track of every newly added field. Thats not a good solution.

bugsysha's avatar

You can always submit a PR to Nova for that feature. That would definitely be the easiest.

and all used packages

This should go into description when creating this topic so people do not miss it like I did.

Please or to participate in this conversation.