How to remove 'label' decorator from Zend 2 form

I have the simple Radio element:

$form->add([
            'name' => 'account_type',
            'type' => 'Zend\Form\Element\Radio',
            'options' => [
                'label' => 'Account type',
                'value_options' => [
                    1 => 'Employer',
                    2 => 'Performer'
                ]
            ]
        ]
    );

But in my view I get this html:

<div class="zf-form-el-account_type">
  <label for="account_type">Account type</label>            
  <div class="zf-radio">
    <label>
      <input type="radio" name="account_type" class="account_type" value="1">Employer
      </label>
  </div>
  <div class="zf-radio">
    <label>
      <input type="radio" name="account_type" class="account_type" value="2">Performer
    </label>            
  </div>
</div>

How I can to remove this empty label wrapper around an radio element? Or how I can to insert some tag after radio element? Thanks.

Answers


I extended standard view helper:

<?php
   namespace Application\Form\View\Helper;

   use Zend\Form\View\Helper\FormRadio;
   use Zend\Form\Element\Radio as RadioEl;

   class FormRadioElement extends FormRadio 
   {
       protected function renderOptions(RadioEl $element, array $options, array $selectedOptions, array $attributes)
       { ...

... and set template in helper like:

$template  = '%s%s';

Then I declared it in my bootstrap:

public function getViewHelperConfig() {
    return [
        'invokables' => [
            'formRadioHelper' => 'Application\Form\View\Helper\FormRadioElement',
        ]              
    ];
}

... and called in my view like:

<?php echo $this->formRadioHelper($form->get('account_type'))?>

Need Your Help

Wishlist member Registration form url not protected

wordpress-plugin

I am using Wishlist member and created an account. The account (level) has a register url ... my problem is that I was able to go straight to the register url and register without paying... I'm I