當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。