Question

I tried it so:

<?php
echo $this->formRow($form->get('weekday'), Zend\Form\View\Helper\FormRow::LABEL_PREPEND);
?>

But the labels are still staying behind the checkboxes.

enter image description here

How should I set the label position correctly?

Was it helpful?

Solution

Is weekday a multi-checkbox? If so, use the render method formMultiCheckbox instead of formRow and the label will be positioned where you want.

I've been debugging the process and that's an strange behaviour. When the class Zend/Form/View/Helper/FormRow is invoked, the label's position is initialized as you expect (LABEL_PREPEND).

Later, the class Zend/Form/View/Helper/FormMultiCheckbox is called but it doesn't inherit the position from FormRow, and uses its default value, which is the one you don't want, LABEL_APPEND.

Check the __invoke method on both classes and you'll see.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top