Issues

ZF-9974: Zend_Form_Element->belongsTo not usable with same named multiple elements

Issue Type: Improvement Created: 2010-06-10T02:07:40.000+0000 Last Updated: 2010-06-10T03:06:06.000+0000 Status: Postponed Fix version(s): - Next Major Release ()

Reporter: Saman Darougheh (excuvator) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: Attachments:

Description

Lets say i want to create two arrays inside one form, using belongsTo: if i want to use they same keys for both arrays, i have to name those elements the same. Unfort., even with different ids, there maynot be more than one element what results in the second element (in this case: remove[$i]) overwriting the first (in this case status[$i]).

class My_Form_Random extends Zend_Form {

public function init()
{
    $data = array(1 => 'test1', 2 => 'test2');
    foreach ($data as $field => $val)
    {
        $this->addStatusElement($field, $field, $val);
        $this->addRemoveElement($field);
    }


    $this->addElement('submit', 'submit');

}

protected function addStatusElement($id, $label, $value)
{
    $element = new Zend_Form_Element_Select('add_'.$id);


    $element->addMultiOption(1);
    $element->addMultiOption(2);

    $element->setBelongsTo('status')
            ->setName($id)
            ->setLabel($label)
            ->setValue($value);
    $this->addElement($element);
}

protected function addRemoveElement($id)
{
    $element = new Zend_Form_Element_Checkbox('remove_'.$id);

    $element->setBelongsTo('remove')
            //->setName($id)
            ->setValue(0)
            ->setLabel('Remove');
    $this->addElement($element);
}

Comments

Posted by Christian Albrecht (alab) on 2010-06-10T03:05:19.000+0000

Postponing for Zend Framework 2.0 development.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts