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

Required attribute missing in form #83

Closed
njansenNL opened this issue Aug 8, 2016 · 10 comments
Closed

Required attribute missing in form #83

njansenNL opened this issue Aug 8, 2016 · 10 comments

Comments

@njansenNL
Copy link

Hi,

I'm creating custom JS-validation on the amforms, however all of a sudden my required attributes are missing on the form fields. Has anyone else had this problem?

I've copied the form-template from the plugin-directory:
/craft/plugins/amforms/templates/_display/form.twig

and targeted it through the backend as the custom-form-template on 1 specific form. The only thing I've changed inside this template is that I've added 2 custom hidden inputs for handling my custom JS-validation, the rest is original.

Hope to hear from anyone soon! 😄

@hubertprein
Copy link
Contributor

The required attribute is handled in the input itself. The required parameter is also available in the field.twig (/craft/plugins/amforms/templates/_display/field.twig). It has nothing to do with the fact that you're not using the default form.twig, but instead use one of your own templates. So I'm guessing the JS you're using is removing the attributes from the fields.

Which version are you using though?

@njansenNL
Copy link
Author

I saw the required attribute in the field.twig, but I didn't modify this template. When I completely disable the JS it still doesn't add the required attributes.

The version we are using is: 1.4.3

Do you have any other suggestions?

@hubertprein
Copy link
Contributor

The default templates should work just fine. Unless you overwritten one from an older version, or some JS is removing these attributes.. otherwise, this should not happen and I can't really reproduce this at the moment. Please check what's happening on your end and if you have any more info (when it really is a plugin bug) to help out reproducing it, that would be appreciated.

@njansenNL
Copy link
Author

Thanks for your response. I'll try to reset the modified files to see if the required attribute is added to the fields. If the problem still exists, I'll try to provide some information about how to re-produce the problem.

@almeric
Copy link

almeric commented Aug 17, 2016

Same problem here, making a field required in the CP doesn't add the required attribute to the input (or add an '*' to the label for that matter). It would be nice to have a required attribute, so we can add some real-time validation on the required fields with javascript/html5 form validation.

This is with no javascript or custom templates.

Example output:

<input class="text nicetext fullwidth" type="text" id="form_v6dFvIkSIF-fields-naam" name="form_v6dFvIkSIF[fields][naam]" value="" data-show-chars-left="" autocomplete="off" placeholder="">

@njansenNL
Copy link
Author

Hi,

It is still not working, I'm digging into the plugin. When I add the required attribute to the following code in: amforms/templates/_display/templates/_components/fieldtypes/PlainText/input.twig

{% set config = {
    id: name,
    name: name,
    value: value,
    class: 'nicetext',
    maxlength: settings.maxLength,
    showCharsLeft: true,
    placeholder: settings.placeholder,
    rows: settings.initialRows,
    type: type is defined ? type : 'text',
    required: true
} %}

The required-attribute is appended to the config variable, but this attribute is missing in the settings value so this value is not parsed. Can u have a look into this?

@SamLNL
Copy link

SamLNL commented Aug 30, 2016

I got the same issue.

What's the status of this problem?

@bengraphite
Copy link

Same here, required comes through as FALSE in the template despite the forms settings

@Teun87
Copy link

Teun87 commented Sep 27, 2016

I'm also having this issue. What is the status? Would be great to see an example HTML fragment with a working 'required-field' setup example.

@hubertprein
Copy link
Contributor

Fixed in the latest release!

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

No branches or pull requests

6 participants