-
Notifications
You must be signed in to change notification settings - Fork 532
Add support for schema.legend & field.id prefixes #206
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
Conversation
* Add support for an optional legend for each schema/fieldset. Expects the schema to look something like this: ``` schema: { legend: "Contact Details", fields: [ { type: "input", inputType: "text", label: "Name", model: "name" }, ... ``` * Add support for field id prefixes, at the form level. So you can add a `fieldIdPrefix: 'prefix_here_'` to your `formOptions` and this will be prepended to _all_ field id's.
I will check it. |
👍 |
One thing, regarding this, should we then use several one for each legend? I would check if in schema exists a property called groups which is an array with objects like {legend:'Something',fields:[]} and if that property doesn't exist then go fields. Definitely, this kind of feature is needed but having more than one tag has no sense for me Cheers, |
@@ -1,6 +1,7 @@ | |||
<template lang="pug"> | |||
div | |||
fieldset.vue-form-generator(v-if='schema != null', :is='tag') | |||
legend(v-if='schema.legend') {{ schema.legend }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a bit more of logic in here to not need more than one tag
@@ -122,6 +123,13 @@ div | |||
} | |||
}, | |||
|
|||
beforeMount() { | |||
// Add idPrefix to fields if fieldIdPrefix is set | |||
for (let field of this.schema.fields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
If you change the schema the Vue will be rebuild the DOM. (I think) I didn't try it. I use to change the complete schema. |
I think is not working for me |
Wow, you are very fast :) Yes, please open a new PR |
Closed by #209 |
fieldIdPrefix: 'prefix_here_'
to yourformOptions
and this will be prepended to all field id's. So if you have this:you'll get this:
So the
idPrefix
is (intentionally) applied to both auto-generated and manually set field ids.I added a
dev/multipleforms
thing to demo this - which should probably be calledmultiplefieldsets
orlegends
or something.