当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form_SubForm::setElementsBelongTo方法代码示例

本文整理汇总了PHP中Zend_Form_SubForm::setElementsBelongTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_SubForm::setElementsBelongTo方法的具体用法?PHP Zend_Form_SubForm::setElementsBelongTo怎么用?PHP Zend_Form_SubForm::setElementsBelongTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form_SubForm的用法示例。


在下文中一共展示了Zend_Form_SubForm::setElementsBelongTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     $this->setAttrib('id', 'org-form-app');
     // subforms
     $organization = new Zend_Form_SubForm();
     $statement = new Zend_Form_SubForm();
     // Set subform where elements belong to avoid name clashing
     $organization->setElementsBelongTo('organizationForm');
     $statement->setElementsBelongTo('statementForm');
     // subform section names
     //$organization->setLegend("ORGANIZATION");
     //$statement->setLegend("STATEMENT OF AGREEMENT AND RESPONSIBILITY");
     // Set the method for the display form to POST
     $this->setMethod('post');
     // ========================================================== add fields
     $this->addOrganizationFields($organization);
     $this->addStatementFields($statement);
     // =====================================================================
     // Add subforms to main form
     $this->addSubForms(array('organization' => $organization, 'statement' => $statement));
     // Add the submit button
     $this->addElement('submit', 'submit', array('class' => 'btn btn-info pull-right', 'ignore' => true, 'label' => 'Submit Application'));
 }
开发者ID:sharsz01,项目名称:acplZend,代码行数:23,代码来源:OrganizationForm.php

示例2: init

 public function init()
 {
     $this->setAttrib('id', 'radio-form-app');
     // subforms
     $listener = new Zend_Form_SubForm();
     $contact = new Zend_Form_SubForm();
     $otherInfo = new Zend_Form_SubForm();
     $statement = new Zend_Form_SubForm();
     // Set subform where elements belong to avoid name clashing
     $listener->setElementsBelongTo('listenerForm');
     $contact->setElementsBelongTo('contactForm');
     $otherInfo->setElementsBelongTo('otherInfoForm');
     $statement->setElementsBelongTo('statementForm');
     //$listener->setElementDecorators(array('ViewHelper', 'Label'));
     //$statement->setElementDecorators(array('ViewHelper', 'Label'));
     // subform section names
     $listener->setLegend("LISTENER");
     $contact->setLegend("ALTERNATIVE CONTACT");
     $statement->setLegend("STATEMENT OF AGREEMENT AND RESPONSIBILITY");
     // Set the method for the display form to POST
     $this->setMethod('post');
     // ========================================================== add fields
     $this->addListenerFields($listener);
     $this->addContactFields($contact);
     $this->addOtherFields($otherInfo);
     $this->addStatementFields($statement);
     // =====================================================================
     // Add subforms to main form
     $this->addSubForms(array('listener' => $listener, 'contact' => $contact, 'otherInfo' => $otherInfo, 'statement' => $statement));
     // Add the submit button
     $this->addElement('submit', 'submit', array('id' => 'submit', 'ignore' => true, 'label' => 'Submit Application', 'class' => 'btn btn-info pull-right'));
     // Add some CSRF protection
     //        $this->addElement('hash', 'csrf', array(
     //            'ignore' => true,
     //        ));
 }
开发者ID:sharsz01,项目名称:acplZend,代码行数:36,代码来源:RadioApplicationForm.php

示例3: testCanValidatePartialNestedFormsWithElementsBelongingToArrays

    public function testCanValidatePartialNestedFormsWithElementsBelongingToArrays()
    {
        $form = new Zend_Form();
        $form->setElementsBelongTo('foobar');

        $form->addElement('text', 'firstName')
             ->getElement('firstName')
             ->setRequired(false);

        $form->addElement('text', 'lastName')
             ->getElement('lastName')
             ->setRequired(true);

        $subForm = new Zend_Form_SubForm();
        $subForm->setElementsBelongTo('foobar[baz]');
        $subForm->addElement('text', 'email')
                ->getElement('email')
                ->setRequired(true)
                ->addValidator('NotEmpty');

        $subSubForm = new Zend_Form_SubForm();
        $subSubForm->setElementsBelongTo('foobar[baz][bat]');
        $subSubForm->addElement('checkbox', 'home')
                   ->getElement('home')
                   ->setRequired(true)
                   ->addValidator('NotEmpty');

        $subForm->addSubForm($subSubForm, 'subSub');

        $form->addSubForm($subForm, 'sub')
             ->addElement('submit', 'save', array('value' => 'submit'));


        $data = array('foobar' => array(
            'lastName'  => 'Cow',
        ));
        $this->assertTrue($form->isValidPartial($data));
        $this->assertEquals('Cow', $form->lastName->getValue());
        $firstName = $form->firstName->getValue();
        $email     = $form->sub->email->getValue();
        $home      = $form->sub->subSub->home->getValue();
        $this->assertTrue(empty($firstName));
        $this->assertTrue(empty($email));
        $this->assertTrue(empty($home));

        $form->sub->subSub->home->addValidator('StringLength', false, array(4, 6));
        $data['foobar']['baz'] = array('bat' => array('home' => 'ab'));

        $this->assertFalse($form->isValidPartial($data), var_export($form->sub->subSub->home, 1));
        $this->assertEquals('1', $form->sub->subSub->home->getValue());
        $messages = $form->getMessages();
        $this->assertFalse(empty($messages));
        $this->assertTrue(isset($messages['foobar']['baz']['bat']['home']), var_export($messages, 1));
        $this->assertTrue(isset($messages['foobar']['baz']['bat']['home']['stringLengthTooShort']));
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:55,代码来源:FormTest.php

示例4: testElementsRenderAsMembersOfSubFormsWithElementsBelongTo

 public function testElementsRenderAsMembersOfSubFormsWithElementsBelongTo()
 {
     $this->form->setName('data')->setIsArray(true);
     $subForm = new Zend_Form_SubForm();
     $subForm->setElementsBelongTo('billing[info]');
     $subForm->addElement('text', 'name');
     $subForm->addElement('text', 'number');
     $this->form->addSubForm($subForm, 'sub');
     $html = $this->form->render($this->getView());
     $this->assertContains('name="data[billing][info][name]', $html);
     $this->assertContains('name="data[billing][info][number]', $html);
     $this->assertContains('id="data-billing-info-name"', $html);
     $this->assertContains('id="data-billing-info-number"', $html);
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:14,代码来源:FormTest.php


注:本文中的Zend_Form_SubForm::setElementsBelongTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。