It's so easy to extend a exists form in drupal,
we just use hook_form_alter to do that
function example_form_alter(&$form, &$form_state, $form_id) {
if ( $form_id == 'user_register_form') {
$form['js_example_form']['fullname'] = array(
'#type' => 'textfield',
'#title' => t('Full Name'),
'#element_validate' => array('example_fullname_validate'),
);
$form['#submit'][] = 'example_fullname_submit';
//$form['#validate'][] = 'example_fullname_validate';}
}
Create a method for validate new form element value
function example_fullname_validate($form, &$form_state) {
$fullname = $form_state['values']['fullname'];
if (empty($fullname)) {
form_set_error('fullname', 'Fullname can not be empty.');
}
}
Save value of fullname
function example_fullname_submit($form, &$form_state) {
$fullname = $form_state['values']['fullname'];
//save fullname here
}
http://www.chromaticsites.com/blog/drupal-tutorial-form-overrides-and-element-specific-validations/
They are many sites to know more words but your site is amazing.. Great job you have done..
ReplyDeleteprofessional website designers