WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Front end validation`

[Resolved] Front end validation`

  • msteel

    @msteelnapcocom

    Is there a way to do front end validation, hopefully with jQuery validate. I see there is some JS validation in the plugin, but it does not seem to work for me, even on a clean install of WP and Pods.

    I need to prevent the custom post type from saving if the required fields are not valid.

    Any help would be appreciated, thanks.

    https://wordpress.org/plugins/pods/

Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Contributor Josh Pollock

    @shelob9

    Can you explain what your needs are as far as validation for the form are? Also what do you mean by “does not seem to work”? Are you getting an error or do you have an expectation that you are unable to fulfill?

    msteel

    @msteelnapcocom

    Thanks for the quick reply. What I meant by “does not seem to work” is that when I attach requirement to a field, say a simple text field, and submit the form I get an error in my console.

    POST http://local.blah.com/email-templates/wp-admin/post.php 500 (Internal Server Error)

    That error does not appear if I remove the requirement, so it seems as if something is trying to happen, but failing.

    Doing a little debugging in jquery.pods.js I can see that the script loads by adding a console.log statement but another console.log within the validate method never fires, so I’m not sure what would be causing the 500 error to begin with (and as I mentioned, it is only there when there is a required field)

    msteel

    @msteelnapcocom

    I should I add, I realize jquery.pods.js validate might be for creating pods, I’m not sure, I’m still ramping up on pods. Loving the plugin, it really is fantastic.

    Plugin Contributor Josh Pollock

    @shelob9

    Can you share the code that you added please? I will have some one take a look and give you some feedback and direction.

    msteel

    @msteelnapcocom

    You mean the code to jquery.pods.js?

    That is simply the console.log statements here...
    
    ( function ( $ ) {
    	console.log('one');
        var pods_changed = false,
            pods_form_field_names = [],
            methods = {
                validate : function () {
    				console.log('two');
                    var $containers = $( 'form.pods-submittable, .pods-validation' ),
                        form_fields = 'input.pods-validate, select.pods-validate, textarea.pods-validate';

    This is on a fresh install of WP and Pods.

    Plugin Contributor Josh Pollock

    @shelob9

    No I meant the code you are adding to attempt to add validation. Sorry I was not clear.

    msteel

    @msteelnapcocom

    I guess my question is, “Is front end validation via javascript something Pods does or is it something I need to develop?”

    msteel

    @msteelnapcocom

    I’m just looking for closure on this. If front end validation is something I need to do I’m happy to do so and try and make it something I can contribute somewhere.

    Thanks,

    -Marc

    Plugin Author Scott Kingsley Clark

    @sc0ttkclark

    Pods handles it’s own validation, but you can use jQuery validation on-top of it when using the public forms. Our validation happens server-side, and we send back an error during processing.

    The error 500 isn’t something that’s normal, so you may want to report that bug on our GitHub and we can work through what exactly is causing that.

    msteel

    @msteelnapcocom

    OK, thanks. I’ve been working on a plugin to handle the validation. I should have it up on GitHub later today or tomorrow and will let you know in case you have any interest in checking it out. It’s working quite well for my needs so far.

    Plugin Contributor Josh Pollock

    @shelob9

    Yes, please share the link here.

    msteel

    @msteelnapcocom

    It still has a ways to go but it seems to work well for most field types. Relation fields and color pickers might need some special love, but in general I’m happy with the start of this. I’m curious what you think.

    https://github.com/mpsteel/pods-validation

    Thanks!

    Plugin Contributor Josh Pollock

    @shelob9

    This looks very promising. Thanks for your work on this. I have not had a chance to test this out yet, just to look at the code. Two things that jumped out at me:

    This plugin will generate fatal errors if Pods isn’t activated. You should set your code to only run if Pods is active. I cover how to do this in my series on creating Pods plugins. We have a full starter plugin for Pods plugins, as well as a simple example of how to safely add code dependent on Pods.

    You are prefixing your php functions with Pods. It is best practice for an add-on plugin to have its own prefix, that way you avoid using a function name that Pods uses, or may use in the future.

    I will take a more detailed look at the plugin tomorrow and provide any additional feedback I can.

    msteel

    @msteelnapcocom

    Thanks for this, yeah I was anxious to get the core functionality down, I’ll make it more formal. I’ve just updated the picks functionality. I know WYSIWYG is not firing properly. I’m sure there’ll be more. Always more… 🙂

    msteel

    @msteelnapcocom

    The plugin has been updated to follow your Pods plugin framework.

    https://github.com/mpsteel/pods-validation

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘[Resolved] Front end validation`’ is closed to new replies.