Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jquery Validation Bundle Laravel Package

boekkooi/jquery-validation-bundle

View on GitHub
Deep Wiki
Context7

Usage

So your done installing. Time to get the validation to the client-side!

It's really simple just open a twig template that has a form and add the following:

{# These are the required libs, you really should move them somewhere else! #}
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js"></script>

{# The code below generates the form validation #}
<script>
    {{ form_jquery_validation(form) }}
</script>

Now go to you page and enjoy.

Additional rules

To get the best result and most client side validations you can enable the additional-methods provided by the bundle. To enable addition-methods you need to enable it in your config.yml by adding:

boekkooi_jquery_validation:
    form:
        ...
        additionals: true

After this you will need to include the additional-methods.min.js within your twig template after jquery.validate.js.

{% javascripts '[@BoekkooiJqueryValidationBundle](https://github.com/BoekkooiJqueryValidationBundle)/Resources/public/additional-methods.min.js' %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

Collection prototype

O no you have a form with a collection that has allow_add set..... Now you need to do more work!

The simple way to enjoy client-side validation with collections is to open you twig template and add the following:

{% form_theme form _self %}

{% block collection_widget %}
    {% if prototype is defined %}
        {# The change here is that we add the javascript for a new row here #}
        {%- set attr = attr|merge({'data-prototype': form_row(prototype) ~ '<script>' ~ form_jquery_validation(form) ~ '</script>'}) -%}
    {% endif %}
    {{- block('form_widget') -}}
{%- endblock collection_widget %}

Now refresh your page and hit that add button.

Validation groups (and buttons)

O yes it's time to abuse the power of the FORM by your usage of buttons with validation groups! No problem we can do that!

Remark If you are using callable validation_groups then please set the jquery_validation_groups option with a array or a string.

More

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle