Can anybody tell me why the following prints out the user_name in a red box but not the t('is not allowed to use this form.')

form_set_error('user_name', t('is not allowed to use this form.'));

Comments

gleble’s picture

This is the context of the offending line. It's driving me mad. Please help someone.

<?php
// $Id$
/**
* @file
* Play with the Form API.
*/
/**
* Implementation of hook_menu().
*/
function formexample_menu() {
$items['formexample'] = array(
'title' => 'View the form',
'page callback' => 'formexample_page',
'access arguments' => array('access content'),
);
return $items;
}
/**
* Menu callback.
* Called when user goes to http://example.com/?q=formexample
*/
function formexample_page() {
$output = t('This page contains our example form.');
// Return the HTML generated from the $form data structure.
$output .= drupal_get_form('formexample_nameform');
return $output;
}
/**
* Define a form.
*/
function formexample_nameform() {
$form['user_name'] = array(
'#title' => l(t('[Your Name]'), 'node/1'),
'#type' => 'textfield',
'#description' => l(t('[edit]'), 'comment/edit/'. $comment->cid),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;

}
coreyp_1’s picture

Are you using a custom theme? If so, does it include the $messages variable in your page template?

- Corey