Issues

ZF-11602: Fatal error: Cannot redeclare class Zend_View_Helper_FormRadio in Unknown on line 0

Description

Hi,

I have come across the error above whilst trying to render a Zend_Form_Element_Radio element into a view script.

Here is my form code


class Consultants_Form_SearchRefine extends Freedom_Zend_Form
{
    /**
     * Occupations Hierarchal tree array
     * @var array|null
     */
    protected $_occupationTree = null;

    /**
     * Set the industries element multi-options
     * @param array $industries
     * @return Consultants_Form_SearchRefine Provides a fluent interface
     */
    public function setIndustries(Array $industries)
    {
        $this->getElement('industries')
            ->setMultiOptions($industries)
            ->setRegisterInArrayValidator(false);
        return $this;
    }

    /**
     * Set the occupations element multi-options
     * @param array $occupations
     * @return Consultants_Form_SearchRefine Provides a fluent interface
     */
    public function setOccupations(Array $occupations)
    {
        $this->getElement('occupations')
            ->setMultiOptions($occupations)
            ->setRegisterInArrayValidator(false);
        return $this;
    }

    /**
     * Sets the occupations hierarchal tree array
     * @param array $occupationsTree
     * @return Consultants_Form_SearchRefine Provides a fluent interface
     */
    public function setOccupationsTree(Array $occupationsTree)
    {
        $this->_occupationTree = $occupationsTree;
        return $this;
    }

    /**
     * Return the occupations tree
     * @throws Zend_Form_Exception
     * @return array Hierarchal tree array
     */
    public function getOccupationTree()
    {
        if (!is_null($this->_occupationTree))
            return $this->_occupationTree;

        throw new Zend_Form_Exception('Occupation tree has not been created');
    }

    /**
     * Setup form, elements, filters and validators
     * @see Zend_Form::init()
     */
    public function init()
    {
        $distance = array();
        for ($i=1;$i<6;$i++) {
            $distance[$i*10] = $i * 10 . ' miles';
        }

        $network = array(
            0   => 'All Candidates',
            1   => 'In My Network',
            2   => 'Everyone Else'
        );

        $this->setName('searchRefine');
        $this->setAction('/consultants/search/results');
        $this->setMethod('post');
        $this->setAttrib('id', 'searchRefineForm');
        $this->setAttrib('class', 'search_form');
        $this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);

        $this->setDecorators(array(
            array('ViewScript', array('viewScript' => 'forms/SearchRefine.phtml'))
        ));

        $this->addElementPrefixPath('Freedom_Zend', 'Freedom/Zend');

        $this->addElement('text', 'keywords', array(
            'required'      => false,
            'attribs'       => array(
                'size'          => '40',
                'title'         => 'Please enter a search term',
                'class'         => 'search_text'),
            'filters'       => array('StringTrim', 'StripTags', 'StripNewlines'),
            'validators'    => array(
                array('StringLength', true, array(
                    'min' => 1,
                    'max' => 200))),
        ));

        $this->addElement('text', 'post_code', array(
            'required'      => false,
            'attribs'       => array(
                'size'          => 6,
                'title'         => 'Please enter a postal code',
                'class'         => 'search_text'),
            'filters'       => array('StripSpaces', 'Alnum'),
            'validators'    => array(
                array('Alnum', true),
                array('StringLength', true, array(
                    'min' => 3,
                    'max' => 6)))
        ));

        $this->addElement('select', 'distance', array(
            'required'      =>false,
            'attribs'       => array(
                'title'         => 'Please select a distance',
                'class'         => 'search_text'),
            'filters'       => array('Int'),
            'multiOptions'  => $distance,
        ));

        $this->addElement('multiCheckbox', 'industries', array(
            'required'      => false,
            'attribs'       => array(
                'class'         => 'industry_checkbox'),
            'filters'       => array('Int'),
        ));

        $this->addElement('multiCheckbox', 'occupations', array(
            'required'      => false,
            'filters'       => array('Int'),
            'validators'    => array(
                array('Int', true))
        ));

        $this->addElement('radio', 'relationship', array(
            'required'      => false,
            'attribs'       => array(
                'class'         => 'network_checkbox'),
            'multiOptions'  => $network,
            'filters'       => array('Int')
        ));
    }
}

And here is my view script


<?php
$attribFilterObj = new Freedom_Zend_Filter_HtmlAttribs();
$attribs = $attribFilterObj->filter($this->element->getAttribs());
?>
>
    
<?php echo $this->element->keywords->renderViewHelper(); ?>
Post Code: <?php echo $this->element->post_code->renderViewHelper(); ?> within <?php echo $this->element->distance->renderViewHelper(); ?>

Industries

<?php echo $this->element->industries->renderViewHelper(); ?>

Occupations

<?php foreach ($this->element->getOccupationTree() as $roots): ?> <?php foreach ($roots['__children'] as $root): ?>

<?php echo $root['occupation'] ?> (<?php echo count($root['__children']); ?>)

<?php foreach ($root['__children'] as $occupation): $checked = ''; if ($occupation['occupation_id'] == $this->element->occupations->getValue()) $checked = ' checked="checked"'; ?> />   <?php echo $occupation['occupation']; ?> (<?php echo $occupation['count']; ?>)
<?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>

Relationship

<?php echo $this->element->relationship->renderViewHelper(); ?>

The radio element 'relationship' is causing the problem, when I change it to multiCheckbox it renders fine.

Kind regards Garry

Comments

No comments to display