Skip to content
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

Group are not flexible enough #259

Closed
lionel-bijaoui opened this issue Jul 17, 2017 · 5 comments
Closed

Group are not flexible enough #259

lionel-bijaoui opened this issue Jul 17, 2017 · 5 comments

Comments

@lionel-bijaoui
Copy link
Member

Hello @icebob @jmverges @dflock
I'm late to the party and I didn't really follow the work on groups.
Since working on #257 , I'm exposed to how group work and I have noticed a flaw in the current design.
I can't alternate freely between single field and group.
The only possibility is fields -> groups. I can't do the inverse (ex. groups -> fields) or anything else (ex. field -> group -> field -> group -> group -> field)
My goal is not to spit on everyone hard work, but I wonder if they can be a better more flexible way to do this.
Why a type: group was not used ?

fields: [{
    type: "input",
    inputType: "text",
    label: "Single field (without group)",
    model: "single"
}, {
    type: "group",
    legend: "Contact Details",
    fields: [{
        type: "input",
        inputType: "text",
        label: "Name",
        model: "name"
    }, {
        type: "input",
        inputType: "email",
        label: "Email",
        model: "email"
    }]
}, {
    type: "group",
    legend: "Other Details",
    fields: [{
        type: "input",
        inputType: "text",
        label: "More",
        model: "others.more"
    }, {
        type: "input",
        inputType: "text",
        label: "Things",
        model: "others.things"
    }]
}]

Thanks for the feedback.

@icebob
Copy link
Member

icebob commented Jul 17, 2017

The current solution was the easiest way to implement it.
If you use groups as a type of field it is more complicated to implement in the template. Need to handle multi-level groups too.

@jamestowers
Copy link

This would be a nice feature, you could potentially set the group tag and className so you're confined to fieldset, eg:

type: "group",
legend: "User details",
tag: "div",
className: "col-6 md-col-12",
fields: [{...}]

@cincarnato
Copy link

I really need this
group
{
className: "col-6 md-col-12",
fields: [..

@zoul0813
Copy link
Member

PR #339 adds "styleClasses" to groups. This allows you to add a "styleClasses" property to your groups, the same way you add it for fields. Coupled with the "tag" property, you can now have groups defined as <div class="col-md-6"></div>, for example.

Sample Use

<vue-form-generator :schema="schema" :model="model" :options="formOptions" tag="div"></vue-form-generator>

Sample Schema

{
    legend: "Group Title",
    styleClasses: "group-class",
    fields: [
        {
            type: "input",
            inputType: "text",
            label: "Text Label",
            model: "text_field",
            styleClasses: "style-class",
            labelClasses: "label-class",
            fieldClasses: "field-class",
        },
    ]
}

@lionel-bijaoui
Copy link
Member Author

Fixed in #484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants