1

I have create a template for user-register page

I have created a module under hook_form_alter as

if($form_id == 'user_register_form') {

            $form['account']['pass']['#type'] = 'password';
            $form['account']['pass']['#title'] = 'Password';
            $form['account']['mail']['#title'] = 'Email';
            $form['actions']['submit']['#value'] = 'Request Access';
             $form['#theme'] = 'user_register';

    }

Edited:

  function custom_user_register_form_validate($form, &$form_state) {

        if($form_state['input']['field_first_name']['und'][0]['value'] == ''){  
            form_set_error('field_first_name', t('Email can not be empty'));
        }
          drupal_set_message($message, 'error');

     if($form_state['input']['field_last_name']['und'][0]['value'] == ''){
        form_set_error('field_last_name', 'Title cannot be "test"');
         drupal_set_message($message, 'error');
     }  

                return $form;
    }

And i have created a user-regiter.tpl.php file

under this i have code like this

 <?php print drupal_render($form['field_first_name']); ?>
<?php print drupal_render_children($form); ?>

Which is working fine

Now when i submit form. it doesnt display error message . But it is showing red border in input box.

Why it is not showing error message . Please help

Thanks

1 Answer 1

0

It's probably because you're not showing the Drupal messages in your theme. Take a look to ensure you have the following (somewhere, probably in your page.tpl.php file);

<?php print $messages; ?>

Note that you've made some other mistakes though (not related to your issue) - First, you should use $form_state['values'] to gain the values when using _validate(); second, you can lose the two drupal_set_message($message, 'error'); lines as they aren't doing anything?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.