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

Form validation is broken #11

Open
tombroucke opened this issue Jun 30, 2022 · 1 comment
Open

Form validation is broken #11

tombroucke opened this issue Jun 30, 2022 · 1 comment

Comments

@tombroucke
Copy link

HTML Forms' validation is based on the form's post meta. When a form is saved in the WP backend, the required & e-mail fields are serialized & saved to _hf_settings. The required fields are extracted with JS from the #hf-form-editor field, which is populated by the post content.

A possible solution would be to ask the HTML forms plugin creator to add a filter to functions.php:100 return $form;, so we can inject our form code (everything inside the

tag). A small tweak to our sage-html-forms/resources/views/components/html-forms.blade.php is needed, so it is similar the original output:

<form {!! $attributes->merge($form->attributes) !!}>
  <input type="hidden" name="_hf_form_id" value="{{ $form->ID }}" />
  <div style="display: none;">
    <input type="text" name="_hf_h{{ $form->ID }}" value="" />
    {!! $hidden !!}
  </div>
  <div class="hf-fields-wrap">
    {!! $slot !!}
    <noscript>Please enable JavaScript for this form to work.</noscript>
  </div>
</form>
@Log1x
Copy link
Owner

Log1x commented Nov 29, 2022

I don't have a solution for this inside of the package but take a look at https://gist.github.com/Log1x/35f3f1f20e430d6a36a0c2e8e8f13ffc if you want to manually add form validation. It also includes an example for implementing Google reCAPTCHA.

@Log1x Log1x mentioned this issue Jul 29, 2023
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

2 participants