-
AuthorPosts
-
June 19, 2014 at 5:35 am #280993
I am trying to create a form for my users to fill out using the contact form that includes multiple row of the same name elements however when I check the page it only shows one row for some reason. How do I make it so I can have multiple rows show up the same?
June 19, 2014 at 5:51 am #281003Hi,
Open contact.php and look for 305-319:
function helper_array2form_fields($base) { $form_fields = array(); if(is_array($base)) { foreach($base as $key => $field) { $form_fields[strtolower($field['attr']['label'])] = $field['attr']; if(!empty($field['content'])) $form_fields[strtolower($field['attr']['label'])]['content'] = ShortcodeHelper::avia_apply_autop($field['content']); } } return $form_fields; }
Replace that by this:
function helper_array2form_fields($base) { $form_fields = array(); $labels = array(); if(is_array($base)) { foreach($base as $key => $field) { $sanizited_id = trim(strtolower($field['attr']['label'])); $labels[$sanizited_id] = empty($labels[$sanizited_id]) ? 1 : $labels[$sanizited_id] + 1; if($labels[$sanizited_id] > 1) $sanizited_id = $sanizited_id . '_' . $labels[$sanizited_id]; $form_fields[$sanizited_id] = $field['attr']; if(!empty($field['content'])) $form_fields[$sanizited_id]['content'] = ShortcodeHelper::avia_apply_autop($field['content']); } } }
This bugfix is already proposed so you don’t have to worry about updates.
Regards,
JosueJune 19, 2014 at 7:42 am #281020Thanks but it didn’t work. I have a child theme and tried modifying the contact.php in the child theme. I cleared my cache out as well. Is there something else I need to do to get it to work?
June 19, 2014 at 7:44 am #281021Try modifying it in the parent theme.
Cheers!
JosueJune 19, 2014 at 7:54 am #281023Didn’t work either. When I replace the code it removes all of the forms on my site except the submit button.
June 19, 2014 at 8:08 am #281028I forgot one line, it should be:
function helper_array2form_fields($base) { $form_fields = array(); $labels = array(); if(is_array($base)) { foreach($base as $key => $field) { $sanizited_id = trim(strtolower($field['attr']['label'])); $labels[$sanizited_id] = empty($labels[$sanizited_id]) ? 1 : $labels[$sanizited_id] + 1; if($labels[$sanizited_id] > 1) $sanizited_id = $sanizited_id . '_' . $labels[$sanizited_id]; $form_fields[$sanizited_id] = $field['attr']; if(!empty($field['content'])) $form_fields[$sanizited_id]['content'] = ShortcodeHelper::avia_apply_autop($field['content']); } } return $form_fields; }
Regards,
JosueJune 19, 2014 at 5:12 pm #281252That did the trick, thanks!
-
AuthorPosts
- The topic ‘Contact Form Issue’ is closed to new replies.