Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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?

    #281003

    Hi,

    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,
    Josue

    #281020

    Thanks 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?

    #281021

    Try modifying it in the parent theme.

    Cheers!
    Josue

    #281023

    Didn’t work either. When I replace the code it removes all of the forms on my site except the submit button.

    #281028

    I 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,
    Josue

    #281252

    That did the trick, thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Contact Form Issue’ is closed to new replies.