Empty Label Decorator
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 28 29 3031 32 33 34 3536 37 38 | <?php class Lib_Form_Decorator_Emptylabel extends Zend_Form_Decorator_Label { /** * Render a empty label * * @param string $content * @return string */ public function render($content) { $element = $this->getElement(); $separator = $this->getSeparator(); $placement = $this->getPlacement(); $label = \"<label> </label>\"; switch ($placement) { case self::APPEND: return $content . $separator . $label; case self::PREPEND: return $label . $separator . $content; } } } /*########### Use of above decorator ########### */ // Creating element : submit $submit = new Llib_Form_Element_Submit(\"submit\"); $submit->setLabel(\"Register\"); $submit->setDecorators(array( \"ViewHelper\", array(\"Emptylabel\",array(\"placement\"=>\"PREPEND\")), array(\"decorator\" => \"HtmlTag\", \"options\" => array(\"tag\" => \"div\", \"class\" => \"form-row\")), )); |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
This Decorator simply add empty label
<label> </label>
in your html. It may be customized to create empty td like <td> </td> or anything as per the requirement.
I used this decorator in one of my project where such empty label was placed before Submit button. But if we simply enable Label decorator like
array("decorator" => "Label")
for form element then it also print the label of the submit button.
Snippet details
- Created:
-
neeraj
- Edited:
-
neeraj
- Revision Id:
- 223
- Edit Message:
- Initial Release
- ZF Version
- 1.8.0
- Tags:
- zend empty label decorator
- Comments:
- 0
- Views:
- 448
- Points:
- 0 (0 votes)