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

CLI-generated form doesn't respect required property of the model #100

Open
e2jk opened this issue Feb 18, 2015 · 0 comments
Open

CLI-generated form doesn't respect required property of the model #100

e2jk opened this issue Feb 18, 2015 · 0 comments

Comments

@e2jk
Copy link
Contributor

e2jk commented Feb 18, 2015

Extract of a model called "object":

    props: {
        id: 'any',
        abbreviation: ['string', true, ''],
        description: ['string', false, ''],

Extract of the form generated by $ ampersand gen form client/models/object.js:

module.exports = FormView.extend({
    fields: function () {
        return [
            new InputView({
                label: "Abbreviation",
                name: "abbreviation",
                value: this.model.abbreviation || "",
                required: false,
                placeholder: "Abbreviation",
                parent: this
            }),
            new InputView({
                label: "Description",
                name: "description",
                value: this.model.description || "",
                required: false,
                placeholder: "Description",
                parent: this
            }),

Both InputView have required: false, while the first one should have been required: true.

The input template is located at lib/templates/input.js and contains the following:

 required: {{{ required }}},

Meaning that the value "false" is not hardcoded. Investigating further, the value of the required variable seems to be determined in lib/gen-types/form.js:

 required: !!definition.required,

That's about as far as I get with my current understanding of Ampersand.js. Does anyone have an idea what's going wrong in this case?

@e2jk e2jk changed the title CLI-generated form doens't respect required property CLI-generated form doesn't respect required property of the model Feb 18, 2015
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

2 participants