aerni / statamic-livewire-forms

Supercharge your Statamic forms with Livewire
https://statamic.com/addons/aerni/livewire-forms
Other
28 stars 2 forks source link

[idea] Automatically overwriting a field view based on the file existing #28

Closed FR6 closed 1 year ago

FR6 commented 1 year ago

Here is some context:

If I have a form group with multiple fields and want to overwrite a specific field, I can't use @formGroup('mygroup') and have to use @formField for all fields just to overwrite one field view:

@formField('field1')
@formField('field2', ['view' => 'field2'])
@formField('field3')
...

A nice feature would be that a view field could be autoloaded if the file with the name of the field exists. ex.: fields/field2.blade.php This way we could still use @formGroup('mygroup') and just by creating the file fields/field2.blade.php we would be able to overwrite it.

To prevent conflict with names, we could use a specific filename syntax: fields/field2--field.blade.php (or anything else)

Let me know what you think.

aerni commented 1 year ago

I like the idea of autoloading a view. Should be fairly simple to implement. Note, that you can already change a view and use the form group by either adding a view property to the field's config in the form blueprint or by creating a form component and overriding it there.