Git Product home page Git Product logo

Comments (7)

jajacobs avatar jajacobs commented on July 22, 2024 1

Hi,
You can just remove your custom error display logic and leave it to the ajax framework. https://octobercms.com/docs/ajax/extras

Btw, nice work!

from october-plugin-forms.

skydiver avatar skydiver commented on July 22, 2024

I was working on the suggestion by @jajacobs and works fine except por recaptcha validation.

Another idea in #35 is to pass a variable with the errors and add some custom javascript to mark the fields.

from october-plugin-forms.

skydiver avatar skydiver commented on July 22, 2024

@Zmove or @jajacobs, can you test the branch "inline-errors" ?

There is a variable in the response and javascript (a new js file is loaded) marks the errors fields ...

This is a demo code i was testing

<form data-request="{{ __SELF__ }}::onFormSubmit" data-request-validate data-request-flash>

    {{ form_token() }}

    <div id="{{ __SELF__ }}_forms_flash"></div>

    <div class="form-group">
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" class="form-control">
        <div data-validate-for="name"></div>
    </div>

    <div class="form-group">
        <label for="email">Email:</label>
        <input type="text" id="email" name="email" class="form-control">
        <div data-validate-for="email"></div>
    </div>

    <div class="form-group">
        <label for="subject">Subject:</label>
        <input type="text" id="subject" name="subject" class="form-control">
    </div>

    <div class="form-group">
        <textarea id="comments" name="comments" rows="8" cols="80"></textarea>
    </div>

    <button id="simpleContactSubmitButton" type="submit" class="btn btn-default">Submit</button>

</form>

Thanks.-

from october-plugin-forms.

jajacobs avatar jajacobs commented on July 22, 2024

Why don't you put <span data-validate-for="g-recaptcha-response"></span> under {% partial '@recaptcha' %} ?

<div class="form-group">
        {% partial '@recaptcha' %}
        <span data-validate-for="g-recaptcha-response"></span>
</div>

from october-plugin-forms.

skydiver avatar skydiver commented on July 22, 2024

The BETA branch has the inline functionality.
Anyone wants to test before release?

Thanks.-

from october-plugin-forms.

skydiver avatar skydiver commented on July 22, 2024

Inline errors was release in version 1.3.7

from october-plugin-forms.

 avatar commented on July 22, 2024

Small question that refer to that issue that was merged with this one.

How do you add an "has-error" class to element that does not validate ?

I red the documentation, was able to display the error message in a div under the field, but I don't see how can I add an error class to the parent div of the field that don't validate.

Thanks for the help

EDIT : And I found a small issue with inline error message (they don't disappears if the form correctly validate a second time). To reproduct :

  • Create a form with inline validation field (required for example)
  • Submit the form with a required field empty, the inline validation message will be displayed
  • Fill that required field, and submit the form again
  • The inline error message will still appears whereas that form element is valid, I think it's a UI issue. The message should disappear.

from october-plugin-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.