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

Field name conflict with custom post type #12

Open
LeBenLeBen opened this issue Aug 1, 2015 · 3 comments
Open

Field name conflict with custom post type #12

LeBenLeBen opened this issue Aug 1, 2015 · 3 comments

Comments

@LeBenLeBen
Copy link

This is probably not a real issue for wp-forms but I just lost an hour resolving the following bug and I just wanted to document it somewhere.

In my form, I had a field named member. I also have a custom post type with the same name. I don’t know exactly why but if I submit the form and the validation doesn’t pass, I get redirected to the correct URL with the 404 template being displayed. I’ve tested with other custom post types and the behaviour is similar. It doesn’t seems to happen with fields named postor page though.

I’ve renamed the field "member_type" and now it works perfectly. Do you have any idea where this conflict could come from and if it could be prevented by wp-forms somehow?

Thanks for this great and highly customisable API by the way.

@korobochkin
Copy link

Yes. This stuff happens inside WordPress core (not inside this plugin). My solution for this issue — just prefix all name attributes with my custom form prefix.

wp_register_form( self::$form_name, array( __CLASS__, 'register_form' ) );

// Somewhere inside register_form()
->add_element(
    WP_Form_Element::create( 'text' )
        ->set_name( self::$form_name . 'name' )
// ...

P. S. I think the author forgot about this repository and now I create forked version of this (you can find it in my Github profile). I've added few custom elements such as markup — any custom html markup inside your form. Support AJAX-form submitting. And now try to fix checkboxes element - they don't save cheched statuses after submit with errors.

@korobochkin
Copy link

Issue about cheched checkboxes fixed: #8

@LeBenLeBen
Copy link
Author

Thanks for the tip! The same problem occurs with radios by the way.

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