You want to add an asterisk to required fields, huh?

There are many approaches to accomplish this. One among them is setting the requiredSuffix option to the label decorator of the form element. Assuming $element is your Zend_Form_Element object:
<?php
$element->getDecorator('label')->setOption('requiredSuffix', ' * ');
?>Another option is to add the * while setting the label.
<?php
$element->setLabel('My Label *')
?>The third, which I am currently using in one of my Zend Framework powered applications is adding * using CSS. The default label decorator generates the following mark-up.
<label class="required" for="username">Email address</label>
Here goes the CSS
.required { background-image:url(/path/to/your/images/dir/required-field.png); background-position:top right; background-repeat:no-repeat; padding-right:10px; }
| Attachment | Size |
|---|---|
| required-field.png | 306 bytes |
Smart solution with CSS, thx
Smart solution with CSS, thx
You're welcome.
You're welcome.
Sudheer
Binary Vibes
You could also go this
You could also go this way:
.required:after
{
content: " *";
}
and then place the star where you want it to be.
Required field
Just to let everyone know:
.required:after
{
content: " *";
}
This doesn't work in IE, so using the PNG image as asterisk is a good choice if you care about those poor people with IE.
So can I add an asterisk to
So can I add an asterisk to required fields of the email php form that i use? How to paste this code there?
Post new comment