Wednesday, July 01, 2009

How to add and validate extra field in contact form (com_contact)

- component/com_contact/views/contact/tmpl/default_form.php
- component/com_contact/views/contact/controller.php

TO MAKE A FIELD VALIDATE ADD class="inputbox required" to input field thats reads as:

Repalce [] with <> below

[input type="text" name="name" id="contact_name" class="inputbox required" value=""]

===============================================

Example: to catch Form post PHONE FIELD

add

$phone = JRequest::getVar( 'phone', '', 'post' );

to line 116 in controller.php

add

.$phone.

to line 178 which reads

$body = $prefix."\n"."Name: ".$name."\n"."Phone: ".$phone.' <'.$email.'>'."\r\n\r\n".stripslashes($body);


To ADD into the default_form.php ADD (remember to replace [] with <> tags below)

[label for="contact_phone"] [?php echo JText::_( 'Phone' );?]:[/label]
[input type="text" name="phone" id="contact_phone" size="30" class="inputbox" value="" /]