Git Product home page Git Product logo

Comments (7)

montchr avatar montchr commented on May 27, 2024 1

I assumed I'd be able to do something similar and the jquery validation would handle the rest

'validation_rules' => ['required' => true], 'validation_messages' => ['required' => 'its required sorry']

This doesn't seem to work and there's not really much documentation as to the format / how this should work.

I tried the same approach and it ended up working out:

'url' => new \Fieldmanager_Link( 'Destination URL', [
    'description'         => 'All messages are linked to a destination page',
    'validation_rules'    => [
        'required' => true,
        'url'      => true,
    ],
    'validation_messages' => [
        'required' => 'Required',
        'url'      => 'This is not a URL!',
    ],
    'attributes' => [
        'placeholder' => 'https://',
    ],
] ),

from wordpress-fieldmanager.

bcampeau avatar bcampeau commented on May 27, 2024

We've already integrated jQuery Validation and you can see the general description of how it works in the comments here: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/master/php/class-fieldmanager-field.php#L131-L153

from wordpress-fieldmanager.

macedd avatar macedd commented on May 27, 2024

I think a working example in the demo would fit well for this feature.

from wordpress-fieldmanager.

netaustin avatar netaustin commented on May 27, 2024

I think ultimately we should be able to PHP-require some fields and allow custom validation callbacks.

from wordpress-fieldmanager.

montchr avatar montchr commented on May 27, 2024

I'd also appreciate a working example of this.

from wordpress-fieldmanager.

simonrcodrington avatar simonrcodrington commented on May 27, 2024

I'd appreciate a working example of this also. The documentation here isn't very helpful: http://api.fieldmanager.org/class-Fieldmanager_Field.html#$validation_rules

I assumed I'd be able to do something similar and the jquery validation would handle the rest

'validation_rules' => ['required' => true], 'validation_messages' => ['required' => 'its required sorry']

This doesn't seem to work and there's not really much documentation as to the format / how this should work.

from wordpress-fieldmanager.

bjorn2404 avatar bjorn2404 commented on May 27, 2024

Came looking for an example but then found in the Fieldmanager_Field class that you want to pass it in as an attribute, which will add the HTML5 required attribute to the field. If it helps, there's an example at http://api.fieldmanager.org/class-Fieldmanager_Field.html#$attributes

from wordpress-fieldmanager.

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.