Zend Framework Source Code Snippets

Empty Label Decorator

Bookmark and Share
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>&nbsp;</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>&nbsp;</label>
in your html. It may be customized to create empty td like <td>&nbsp;</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 neeraj
2 months ago
Edited:
neeraj neeraj
2 months ago
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)

History

r223

Initial Release

neeraj neeraj
2 months ago
diff
r222

Initial Release

neeraj neeraj
2 months ago
diff
r221

Initial Release

neeraj neeraj
2 months ago
diff
r220

Initial Release

neeraj neeraj
2 months ago