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

Bootsrap Form #38

Open
lestercomia opened this issue Nov 22, 2017 · 3 comments
Open

Bootsrap Form #38

lestercomia opened this issue Nov 22, 2017 · 3 comments

Comments

@lestercomia
Copy link

lestercomia commented Nov 22, 2017

When using a bootstrap form module and using norecaptcha. Validation Error wont show up.

see nocaptcha/lang/en.yml

`
en:
NocaptchaField:

    EMPTY: "Please answer the captcha, if you do not see the captcha please enable JavaScript"

    NOSCRIPT: "You must enable JavaScript to submit this form"

    VALIDATE_ERROR: "Captcha could not be validated"

`

@UndefinedOffset
Copy link
Owner

What version of SilverStripe are you using? If you are using SilverStripe 4 make sure you are using the latest from master or 2.0.0-alpha2. If you are using SilverStripe 3 make sure you are using 1.0.0 or the latest from 1.0.x.

Also is the error message simply blank? It's also possible if bootstrap is intercepting the submission process for the form you may need to trigger the recaptcha api manually.

@UndefinedOffset
Copy link
Owner

UndefinedOffset commented Nov 22, 2017

Also note the validation error message will only show after submission to the server as validation is done server side. It will not show up prior to that.

@a2nt
Copy link
Contributor

a2nt commented Dec 10, 2018

Guess this note will be helpful.

If u have custom validator class u will need to check every field manually, ex:

class MyCustomValidator extends Validator {
   public function php($data)
   {
       $valid = true;
        $fields = $this->Form()->Fields();
        foreach($fields as $field) {
           $valid = $valid && $field->validate();
         }
         // your custom validation
         return $valid;
   }
}

but if u will extend SilverStripe\Forms\RequiredFields it will work ok:

class MyCustomValidator extends RequiredFields {
   public function php($data)
   {
        $valid = parent::php($data);
        // your custom code
        return $valid;
   }
}

bootstrap form module + norecaptcha works ok without custom validation.

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

3 participants