• Resolved Norman Cates

    (@normancates)


    I note that the name property of the form fields in the rendered HTML is always something like

    name="wpforms[fields][3]"

    I understand why, in that it will be information about the data structure to put the information into.

    However, it breaks the browser capabilities of filling in form fields that have previously been used and entered. Because the name of the form field does not match.

    It would be useful from a customer point of view to have the option to make certain form fields have a specific name property.

    However, I appreciate this is likely to cause problems with your capability of creating arbitrary form fields.

    Nevertheless, would a custom name property on at least some of the common form fields be possible?

    Thanks,

    Norman

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @normancates,

    Thanks for reaching out!

    We don’t currently have a built-in way to change the field name property. I do agree it would be super helpful, though. I’ve made a note of the feature request and we’ll keep it on our radar as we plan out our roadmap for the future.

    However, if you’re willing, this can be accomplished with our wpforms_field_properties filter, and here is our guide about this filter.

    So, you could use a little custom code like this:

    /**
     * Custom function to change the 'name' property of fields in any form.
     *
     * @param array  $properties The field properties.
     * @param array  $field      The field data.
     * @param array  $form_data  The form data.
     * @return array
     */
    add_filter('wpforms_dev_field_properties', function ($properties, $field, $form_data) {
     
            $properties['inputs']['primary']['attr']['name'] = 'new_field_name';
    
        return $properties;
    }, 10, 3);

    In case it helps, here’s our tutorial with the most common ways to add custom code like this.

    For the most beginner-friendly option in that tutorial, I’d recommend using the WPCode plugin.

    I hope this helps!

    Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @normancates,

    We haven’t heard back from you in a few days, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is it possible to set the name property of form fields?’ is closed to new replies.