Hello,

I'm having a problem with Zend_Form trying to set up a group of Text boxs +
combo box

I whant to set a group like 
Service[0] [typeofservice]  = "XXX";
Service[0] [numberofservice]  = "XXX";
Service[0] [typeofservice2]  = "XXX";
Service[0] [numberofservice2]  = "XXX";


Service[1] [typeofservice]  = "XXX";
Service[1] [numberofservice]  = "XXX";
Service[1] [typeofservice2]  = "XXX";
Service[1] [numberofservice2]  = "XXX";

Doing a var_dump($_POST['servico'] I can see the values, but using
var_dump($form->getValues()) the boxs appear filled with the number "3". 

Any sugestions to this issue or problem will be helpfull.

Also if anyone can provide an example of the correct way of doing this with
Zend_Form I'll be gratefull.


Thank you in advance,
FR

Code bellow:
    public function servico()
    {
        $form = new Zend_Form_SubForm();
        $form->setAttribs(array(
            'name' => 'servicos',
            'legend' => 'Serviços'
                )
        );
        
        $form->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'ul')),
            'Form',
        ));

        for ($i = 0; $i < 4; $i++) {
            $form->addSubForm($this->verServico($i), "servico" . $i);
        }

        return $form;
    }

    public function verServico($i)
    {
        $sub = new Zend_Form_SubForm();

        $sub->clearDecorators();

        $sub->setAttribs(array(
            'name' => 'textboxtab' . $i,
            'legend' => 'Serviço ' . ($i + 1)
                )
        );
        $sub->setIsArray(false);

        $sub->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'li')),
            'Form',
        ));
        
        $sub->clearAttribs();

        $net = new Zend_Form_Element_Select("serviconet" . $i);
        $net->setLabel('Serviço ' . ($i + 1) . " Internet")
                ->setMultiOptions($this->servicosNet)
                //->setValue($this->getdata("serviconet"))
                ->setOptions(array(
                    "onChange" => "formclienteComboNet('" . "serviconet" .
$i . "');"
                        )
                )
                ->setBelongsTo("serviconet" . $i);

        $sub->addElement($net);

        $netmac = new Zend_Form_Element_Text("macaddr" . $i);
        $netmac->setBelongsTo("serviconet" . $i);
        $netmac->setLabel("Modem Mac Address (HFC MAC)");
        $sub->addElement($netmac);

        // Telefone
        $tel = new Zend_Form_Element_Select("servicotela" . $i);
        $tel->setLabel("Telefone")
                ->setBelongsTo("serviconet" . $i)
                ->setMultiOptions($this->servicosTelef)
                //->setValue($this->getdata("servicotelef"))
                ->setOptions(array(
                    "onChange" => "formclienteComboTel('" . "servicotela" .
$i . "');"
                        )
                )
                ->setRegisterInArrayValidator(false);
        $sub->addElement($tel);

        $telnum = new Zend_Form_Element_Text("tel" . $i);
        $telnum->setBelongsTo("serviconet" . $i);
        $telnum->setLabel("Número");
        $sub->addElement($telnum);

        $sub->setElementDecorators(array(
            'ViewHelper',
            'Label',
            'Errors',
            new Zend_Form_Decorator_HtmlTag(array('tag' => 'span')) //wrap
elements in <li>'s
                ), array("macaddr" . $i,
            "tel" . $i,
            "servicotela" . $i,
            "serviconet" . $i
                )
        );

        $netmac->addDecorator(
                array('row' => 'HtmlTag'), array('tag' => 'div')
        );

        $row = $netmac->getDecorator("row");
        $row->setOption("style", "display: none;")
                ->setOption("id", "divmemac" . "serviconet" . $i)
        ;

        $telnum->addDecorator(
                array('row' => 'HtmlTag'), array('tag' => 'div')
        );

        $row = $telnum->getDecorator("row");
        $row->setOption("style", "display: none;")
                ->setOption("id", "divme" . "servicotela" . $i)
        ;

        return $sub;
    }

--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Form-subforms-and-setBelongsTo-x-tp4105411p4105411.html
Sent from the Zend Framework mailing list archive at Nabble.com.

--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to