-
Notifications
You must be signed in to change notification settings - Fork 533
optional template slot for labels #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is related to #373 but my approach is slightly different to what was proposed I think |
I think the best approach is to use mixins, and just expose all fields publically so they can be used as a mixin. The user would then just create a template and use their own layout while inheriting all of the fields functionality (optionally able to override/extend functionality). In addition, things like the label and error text layout should be managed by a generic component and not the main VFG component, which would allow users the ability to override or replace this as well. The end result is that we don’t have to add anything or increase the overall code size to account for user contributes templates, and just harness the power of mixins out of the box. |
I don't get it entirely. You are talking about adding a mixin to the vue-form-generator main component that changes the template to put a custom component instead of {{label}}, am i right? The template slot logic I propose does not put some more code into this repo, apart of calling the slot. The code sample I wrote is a template that is outside of the vue-form-generator repo. It's the end user that writes that. And by default if he does write the template and use the current way of calling the component, the behaviour would be the same. Like that it would be possible to put some condition to display the field in another way according to a condition (if field.featured, if field.myCustomProperty ...) If I can get how you prefer it implemented, I can still take that in charge :D |
And I realized I made errors in the sample...
If you want a real world example, have a look at buefy. Here is an example of customizing headers of the table component : https://codepen.io/pen?&editors=101 |
@lionel-bijaoui can this be closed? |
Yes |
Hi,
Would it be a good idea to let users implement (optionnally) a template for form fields ?
By default, without writing the template slot, the behaviour would be the actual one.
It is also conceivable to implement the same logic for fields wrappers.
Like that, it would be possible to implement collapsible fields for instance.
Thoughts?
If you think it is a good idea I can have a look at it.
The text was updated successfully, but these errors were encountered: