Bug Report: Empty form fields are not in $_POST = error in render-form.php

This topic contains 2 reply and 2 voices, and was last updated by Tareq Hasan 10 years, 6 months ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
September 9, 2013 at 3:08 am 7937
Tareq Hasan WP User Frontend Pro (v2.1.7) WordPress (v3.6) Summary: PHP Notice due to Undefined index stalls AJAX. Where: function prepare_meta_fields() in class/render-form.php To reproduce:
  • Create a new Registration Form.
  • Add the First Name field and make it required.
  • Add a checkbox field named 'my_checkbox' and make it NOT required.
  • Add any three options to the checkbox field.
  • Publish the form.
  • Place the Edit Profile shortcode on a page.
  • Visit the page with the Edit Profile form.
  • Submit the form without checking any options for the checkbox field.
Error:
[Sun Sep 08 15:49:40 2013] [error] [client 127.0.0.1] PHP Notice: Undefined index: my_checkbox in /Users/bpk/Sites/local.wordpress.dev/public/wp-content/plugins/wp-user-frontend-pro/class/render-form.php on line 211, referer: http://local.wordpress.dev/wpuf-profile-form-field-tests/?msg=profile_update [Sun Sep 08 15:49:40 2013] [error] [client 127.0.0.1] PHP Notice: Undefined index: my_checkbox in /Users/bpk/Sites/local.wordpress.dev/public/wp-content/plugins/wp-user-frontend-pro/class/render-form.php on line 214, referer: http://local.wordpress.dev/wpuf-profile-form-field-tests/?msg=profile_update
Details: If a checkbox field is NOT required, the Edit Profile form can be submitted without any selected (checked) options. With no options checked, $_POST does not include this checkbox field as an index in the array. In class/render-form.php, the prepare_meta_fields function loops over ALL the fields defined in the form, but on Line 211 we get an error because the checkbox field name is not in $_POST. $_POST[$value['name']] $_POST['my_checkbox'] is not set.
September 9, 2013 at 3:47 am 7941
lfd lfd

Sorry, I shouldn’t have noted that this only stalls AJAX when WP_DEBUG is true.

September 9, 2013 at 7:26 am 7943
Tareq Hasan Tareq Hasan

Hello Brian, thats a great bug report. Not that the bug is great, but the report is 🙂

Obviously that’ll only work when WP_DEBUG is true, but I’ll fix it in the next version. Thanks for the report.

Viewing 2 Posts - 1 through 2 (of 2 total)