Zend Framework Checkbox Decorators

11,675

Solution 1

$this->getElement('elementId')->addDecorator('Label', array('placement' => 'APPEND'))

the placement option can take APPEND or PREPEND as value

Solution 2

I know that is an older question, but you can also use

$element->getDecorator('label')->setOption('placement', 'APPEND');

if it is an already created element with an existing decorator

Share:
11,675
Richard Knop
Author by

Richard Knop

I'm a software engineer mostly working on backend from 2011. I have used various languages but has been mostly been writing Go code since 2014. In addition, I have been involved in lot of infra work and have experience with various public cloud platforms, Kubernetes, Terraform etc. For databases I have used lot of Postgres and MySQL but also Redis and other key value or document databases. Check some of my open source projects: https://github.com/RichardKnop/machinery https://github.com/RichardKnop/go-oauth2-server https://github.com/RichardKnop

Updated on July 27, 2022

Comments

  • Richard Knop
    Richard Knop almost 2 years

    What I am trying to accomplish is to have checkbox labels display after checkbox input fields (to the right of them).

    I am using these decorators now:

    private $checkboxDecorators = array(
        Label,
        array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'checkbox')),
        'ViewHelper',
        array(array('row' => 'HtmlTag'), array('tag' => 'li')),
    );
    

    I have tried switching the Label and ViewHelper decorators but that did nothing. Any suggestions?

  • Phliplip
    Phliplip over 13 years
    I needed that! Or you could use $this->getElement('elementId')->getDecorator('label')->setOp‌​tion('placement', 'APPEND');