Re: Quickform: static type needs colspan
| From: | Wojciech Gdela | Date: | Wed, 26 Feb 2003 20:57:12 +0000 |
| Subject: | Re: Quickform: static type needs colspan | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3983@lists.php.net to get a copy of this message | ||
Dan Wilson wrote:
> $reason set above based on reason for not logging in... I'm using in
> conjunction with PEAR::Auth
>
> $form = new HTML Quickform('login');
>
> $reason = '<div style="color: red">' . $reason .
> '</div>';
>
> $form->addElement('static', null, $reason);
> $form->addElement('text', 'username', 'Username:', $username);
> $form->addElement('password', 'password', 'Password:');
> $form->addRule('username', 'Username is required',
> 'required');
> $form->addRule('password', 'Password is required',
> 'required');
> $form->addElement('submit', 'submit', 'Submit');
>
> > > The new static type is great, but it doesn't have a colspan... it only appears
> > > in the first column with the element labels.
The intention of static was to use it like any other element (i. e. text
box), so it has a name (in first column) and value (in second column).
This code:
$form->addElement('static', null, 'Name:', 'value');
$form->addElement('text', 'username', 'Username:',
'wojtek');
Would produce output like this:
Name: value
Username: [ wojtek ]
In your case you can use either addData (I don't like this one);
$form->addData('<tr><td colspan="2">' . $reason .
'</td></tr>');
Or (I would prefer this, but it would not display in colspaned row):
$form->addElement('text', 'username', 'Username:', $username);
$form->addElement('password', 'password', 'Password:');
$form->addRule('username', 'Username is required', 'required');
$form->addRule('password', 'Password is required', 'required');
$form->addElement('submit', 'submit', 'Submit');
function login_ok($element, $username)
{
// check login and pass here and return true if ok
}
$form->registerRule('checklogin', 'function', 'login_ok');
$form->addRule('username', 'Wrong login', 'login_ok',
'function');
See also: HTML_QuickForm/docs/QuickForm_example3.php
- Wojtek