Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #276850

    Thank you in advance for your assistance. I want to do two things:

    1) Center align the form element field in the contact form on the main page of my website. I would also like to center align the text in this field.
    2) I also would like the “Name” in the field to exist within the element field within the contact form, allowing the user to erase the text and enter his or her own name, email, etc.

    If there is too much custom coding involved, if you could just point me in the right direction I would be greatful. Thank you!

    #276879

    Hey webdevsd!

    1) If you want to center align the text of the input field add this code to the quick css field:

    
    #top .avia_ajax_form .text_input{
    text-align: center;
    }
    

    2) In wp-content/themes/enfold/framework/php/class-form-generator.php replace:

    
    		function text($id, $element)
    		{
    			$p_class = $required = $element_class = $value = "";
    			
    			$type = 'text';
    			// if($element['check'] == "is_email") $type = 'email'; //cant use this because of ie8 + 9
    			
    			if(!empty($element['check']))
    			{
    				$required = ' <abbr class="required" title="required">*</abbr>';
    				$element_class = $element['check'];
    				$p_class = $this->check_element($id, $element);
    			}
    
    			if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);
    
    			$this->elements_html .= "<p class='".$p_class.$element['class']."' id='element_$id'>";
    			$form_el = ' <input name="'.$id.'" class="text_input '.$element_class.'" type="'.$type.'" id="'.$id.'" value="'.$value.'"/>';
    			$label = '<label for="'.$id.'">'.$element['label'].$required.'</label>';
    
    			if(isset($this->form_params['label_first']))
    			{
    				$this->elements_html .= $label.$form_el;
    			}
    			else
    			{
    				$this->elements_html .= $form_el.$label;
    			}
    
    			$this->elements_html .= "</p>";
    		}
    

    with

    
    		function text($id, $element)
    		{
    			$p_class = $required = $element_class = $value = "";
    			
    			$type = 'text';
    			// if($element['check'] == "is_email") $type = 'email'; //cant use this because of ie8 + 9
    			
    			if(!empty($element['check']))
    			{
    				$required = ' <abbr class="required" title="required">*</abbr>';
    				$element_class = $element['check'];
    				$p_class = $this->check_element($id, $element);
    			}
    
    			if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);
                if(empty($value)) $value = $element['label'];
    
    			$this->elements_html .= "<p class='".$p_class.$element['class']."' id='element_$id'>";
    			$form_el = ' <input name="'.$id.'" class="text_input '.$element_class.'" type="'.$type.'" id="'.$id.'" value="'.$value.'"/>';
    			$label = '<label for="'.$id.'">'.$element['label'].$required.'</label>';
    
    			if(isset($this->form_params['label_first']))
    			{
    				$this->elements_html .= $label.$form_el;
    			}
    			else
    			{
    				$this->elements_html .= $form_el.$label;
    			}
    
    			$this->elements_html .= "</p>";
    		}
    

    and

    
    		function textarea($id, $element)
    		{
    			$p_class = $required = $element_class = $value = "";
    
    			if(!empty($element['check']))
    			{
    				$required = ' <abbr class="required" title="required">*</abbr>';
    				$element_class = $element['check'];
    				$p_class = $this->check_element($id, $element);
    			}
    
    			if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);
    
    			$this->elements_html .= "<p class='".$p_class.$element['class']."' id='element_$id'>";
    			$this->elements_html .= '	 <label for="'.$id.'" class="textare_label hidden textare_label_'.$id.'">'.$element['label'].$required.'</label>';
    			$this->elements_html .= '	 <textarea name="'.$id.'" class="text_area '.$element_class.'" cols="40" rows="7" id="'.$id.'" >'.$value.'</textarea>';
    			$this->elements_html .= "</p>";
    		}
    

    with

    
    		function textarea($id, $element)
    		{
    			$p_class = $required = $element_class = $value = "";
    
    			if(!empty($element['check']))
    			{
    				$required = ' <abbr class="required" title="required">*</abbr>';
    				$element_class = $element['check'];
    				$p_class = $this->check_element($id, $element);
    			}
    
    			if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);
                if(empty($value)) $value = $element['label'];
    
    			$this->elements_html .= "<p class='".$p_class.$element['class']."' id='element_$id'>";
    			$this->elements_html .= '	 <label for="'.$id.'" class="textare_label hidden textare_label_'.$id.'">'.$element['label'].$required.'</label>';
    			$this->elements_html .= '	 <textarea name="'.$id.'" class="text_area '.$element_class.'" cols="40" rows="7" id="'.$id.'" >'.$value.'</textarea>';
    			$this->elements_html .= "</p>";
    		}
    

    If you want to overwrite the contact form class with a child theme I recommend to copy the entire class within the file (starting with:

    
    if( ! class_exists( 'avia_form' ) )
    
    

    into your child theme functions.php file and to modify the code there.

    Regards,
    Peter

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.