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

Consistent ‘Missing required field’ with Form 1.3.0-rc.4 and Grav 1.0.10 #78

Closed
nclm opened this issue Jun 27, 2016 · 5 comments
Closed
Assignees
Labels

Comments

@nclm
Copy link

nclm commented Jun 27, 2016

(source)

Using Grav 1.0.10, and the Form plug-in updated from 1.2.2 to 1.3.0-rc.4, the two forms I have on the installation get the same issue. When submitting, this error happens:

Validation failed: Missing required field:

All the fields have been filled. The falsely missing field varies, a File input for one, and ReCaptcha for the other. When reverting back to 1.2.2, the forms work again.

@flaviocopes flaviocopes self-assigned this Jun 27, 2016
@flaviocopes
Copy link
Contributor

Cannot replicate - what's the form definition?

@nclm
Copy link
Author

nclm commented Jun 27, 2016

Here’s one:

form:
    action: /contact
    name: contact
    fields:
        -
            name: name
            label: 'Your full name'
            placeholder: 'Full name'
            type: text
            autofocus: 'on'
            validate:
                required: true
        -
            name: company
            label: 'Your company'
            placeholder: Company
            type: text
        -
            name: email
            label: 'Your e-mail address'
            placeholder: 'E-mail address'
            type: email
            validate:
                rule: email
                required: true
        -
            name: phone
            label: 'Your phone number'
            placeholder: 'Phone number'
            type: text
        -
            name: message
            label: 'Your message'
            placeholder: Message
            type: textarea
            validate:
                required: true
        -
            name: g-recaptcha-response
            label: Validation
            type: captcha
            recatpcha_site_key: XXX
            recatpcha_not_validated: 'Incorrect validation'
            validate:
                required: true
    buttons:
        -
            type: submit
            value: Send
    process:
        -
            captcha:
                recatpcha_secret: XXX
        -
            email:
                from: '{{ form.value.email }}'
                from_name: '{{ form.value.name|e }}'
                to: '{{ config.plugins.email.to }}'
                subject: '[Sitename] Message from {{ form.value.name|e }}{% if form.value.company %} ({{ form.value.company|e }}){% endif %}'
                body: '{% include ''forms/data.html.twig'' %}'
        -
            save:
                fileprefix: contact-
                dateformat: Ymd-His-u
                extension: txt
                body: '{% include ''forms/data.txt.twig'' %}'
        -
            message: 'Message sent.'
        -
            display: ok

and the other:

form:
    name: candidature
    fields:
        -
            name: offre
            label: 'What job offer are you answering to?'
            type: text
            autofocus: 'on'
            placeholder: Position
            validate:
                required: true
        -
            name: name
            label: 'Your full name'
            placeholder: 'Full name'
            type: text
            validate:
                required: true
        -
            name: email
            label: 'Your e-mail address'
            placeholder: 'E-mail address'
            type: email
            validate:
                rule: email
                required: true
        -
            name: phone
            label: 'Your phone number'
            placeholder: 'Phone number'
            type: text
            validate:
                required: true
        -
            name: cv
            label: 'Your CV'
            type: file
            multiple: false
            destination: user/data/cv
            accept:
                - 'application/*'
            validate:
                required: true
        -
            name: lettre
            label: 'Your cover letter'
            placeholder: 'Cover letter'
            type: textarea
            validate:
                required: true
        -
            name: g-recaptcha-response
            label: Validation
            type: captcha
            recatpcha_site_key: XXX
            recatpcha_not_validated: 'Incorrect validation.'
            validate:
                required: true
    buttons:
        -
            type: submit
            value: Apply
    process:
        -
            captcha:
                recatpcha_secret: XXX
        -
            email:
                from: '{{ form.value.email }}'
                from_name: '{{ form.value.name|e }}'
                to: '{{ config.plugins.email.to }}'
                subject: '[Sitename][Job] Application from {{ form.value.name|e }} for "{{ form.value.offre|e }}"'
                body: '{% include ''forms/data.html.twig'' %}'
        -
            save:
                fileprefix: jobs-
                dateformat: Ymd-His-u
                extension: txt
                body: '{% include ''forms/data.txt.twig'' %}'
        -
            message: 'Application sent.'
        -
            display: ok

@flaviocopes
Copy link
Contributor

Thanks, replicated

@flaviocopes
Copy link
Contributor

Ok there is a problem with setting

validate:
  required: true

on Captcha and File fields.

For captcha, you don't need to set it, as if the field is added, it's already being required automatically.
And in Grav 1.1 it's working even if set as required.

For the file field however, it's not working in Grav 1.1 too, because it's a special field (file upload) it needs some special handling. Looking at it.

@flaviocopes
Copy link
Contributor

Pushed a fix in Grav 1.1

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

No branches or pull requests

2 participants