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


PHP Zend_Form::setElementsBelongTo方法代码示例

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


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

示例1: addSubForm

 public function addSubForm(Zend_Form $form, $name, $order = null)
 {
     $form->loadDefaultDecorators();
     $form->removeDecorator('Form');
     $form->addDecorator('Fieldset')->addDecorator('DtDdWrapper');
     $form->setElementsBelongTo($name);
     return parent::addSubForm($form, $name, $order);
 }
开发者ID:laiello,项目名称:wanderson,代码行数:8,代码来源:FormAbstract.php

示例2: testLabelIdIsCorrect

 public function testLabelIdIsCorrect()
 {
     $form = new \Zend_Form();
     $form->setElementsBelongTo('comment');
     $this->element->setLabel("My Captcha");
     $form->addElement($this->element);
     $html = $form->render($this->getView());
     $expect = sprintf('for="comment-%s-input"', $this->element->getName());
     $this->assertRegexp("/<label [^>]*?{$expect}/", $html, $html);
 }
开发者ID:stunti,项目名称:zf2,代码行数:10,代码来源:FigletTest.php

示例3: testElementsRenderAsSubArrayMembersWhenElementsBelongToASubArray

 public function testElementsRenderAsSubArrayMembersWhenElementsBelongToASubArray()
 {
     $this->setupElements();
     $this->form->setElementsBelongTo('data[foo]');
     $html = $this->form->render($this->getView());
     $this->assertContains('name="data[foo][foo]"', $html);
     $this->assertContains('name="data[foo][bar]"', $html);
     $this->assertContains('name="data[foo][baz]"', $html);
     $this->assertContains('id="data-foo-foo"', $html);
     $this->assertContains('id="data-foo-bar"', $html);
     $this->assertContains('id="data-foo-baz"', $html);
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:12,代码来源:FormTest.php

示例4: setValue

 /**
  * Set element value
  *
  * @param  mixed $value
  * @return \MUtil_Form_Element_Table (continuation pattern)
  */
 public function setValue($value)
 {
     // $this->setElementsBelongTo($this->getName());
     if ($this->_subForm && $value) {
         $this->_subForm->setElementsBelongTo($this->getName());
         foreach ($value as $id => $row) {
             if (isset($this->_subForms[$id])) {
                 $this->_subForms[$id]->populate($row);
             } else {
                 $subForm = clone $this->_subForm;
                 $name = $this->getName() . '[' . $id . ']';
                 $subForm->setElementsBelongTo($name);
                 $subForm->setName($name);
                 $subForm->populate($row);
                 $this->_subForms[$id] = $subForm;
             }
         }
     }
     return parent::setValue($value);
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:26,代码来源:Table.php

示例5: addSubForm

 /**
  * Add a form group/subform
  *
  * @param  Zend_Form $form
  * @param  string $name
  * @param  int $order
  * @return Zend_Form
  */
 public function addSubForm(Zend_Form $form, $name, $order = null)
 {
     $name = (string) $name;
     /** @var Zend_Loader_PluginLoader $loader */
     foreach ($this->_loaders as $type => $loader) {
         $loaderPaths = $loader->getPaths();
         foreach ($loaderPaths as $prefix => $paths) {
             foreach ($paths as $path) {
                 $form->addPrefixPath($prefix, $path, $type);
             }
         }
     }
     if (!empty($this->_elementPrefixPaths)) {
         foreach ($this->_elementPrefixPaths as $spec) {
             list($prefix, $path, $type) = array_values($spec);
             $form->addElementPrefixPath($prefix, $path, $type);
         }
     }
     if (!empty($this->_displayGroupPrefixPaths)) {
         foreach ($this->_displayGroupPrefixPaths as $spec) {
             list($prefix, $path) = array_values($spec);
             $form->addDisplayGroupPrefixPath($prefix, $path);
         }
     }
     if (null !== $order) {
         $form->setOrder($order);
     }
     if (($oldName = $form->getName()) && $oldName !== $name && $oldName === $form->getElementsBelongTo()) {
         $form->setElementsBelongTo($name);
     }
     $form->setName($name);
     $this->_subForms[$name] = $form;
     $this->_order[$name] = $order;
     $this->_orderUpdated = true;
     return $this;
 }
开发者ID:bartolomeu,项目名称:estoque_gusella,代码行数:44,代码来源:Form.php

示例6: 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

示例7: getForms

 /**
  * Возвращает массив объектов Zend_Form мини-форм по типам 
  *
  * @return array
  */
 public function getForms()
 {
     $forms = array();
     foreach ($this->configs as $fieldtype => $template) {
         $form = new Zend_Form($template);
         $form->setElementsBelongTo('fields[]');
         $form->addDisplayGroup(array_keys($template['elements']), 'main', array('legend' => $template['label'], 'class' => 'ui-widget-content'));
         $form->removeDecorator('Form');
         $form->removeDecorator('DtDdWrapper');
         $form->setTranslator($this->translate);
         $forms[$fieldtype] = $form;
     }
     return $forms;
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:19,代码来源:FormsElements.php

示例8: testCanGetMessagesOfNestedFormsWithMultiLevelElementsBelongingToArrays

 public function testCanGetMessagesOfNestedFormsWithMultiLevelElementsBelongingToArrays()
 {
     $this->_checkZf2794();
     $form = new Zend_Form();
     $form->setElementsBelongTo('foo[bar]');
     $form->addElement('text', 'firstName')->getElement('firstName')->setRequired(false);
     $form->addElement('text', 'lastName')->getElement('lastName')->setRequired(true);
     $subForm = new Zend_Form_SubForm();
     $subForm->setElementsBelongTo('baz');
     $subForm->addElement('text', 'email')->getElement('email')->setRequired(true)->addValidator('NotEmpty');
     $subSubForm = new Zend_Form_SubForm();
     $subSubForm->setElementsBelongTo('bat[quux]');
     $subSubForm->addElement('checkbox', 'home')->getElement('home')->setRequired(true)->addValidator('InArray', false, array(array('1')));
     $subForm->addSubForm($subSubForm, 'subSub');
     $form->addSubForm($subForm, 'sub')->addElement('submit', 'save', array('value' => 'submit'));
     $data = array('foo' => array('bar' => array('lastName' => 'Cow')));
     $form->sub->subSub->home->addValidator('StringLength', false, array(4, 6));
     $data['foo']['bar']['baz'] = array('bat' => array('quux' => array('home' => 'ab')));
     $form->isValidPartial($data);
     $messages = $form->getMessages();
     $this->assertFalse(empty($messages));
     $this->assertTrue(isset($messages['foo']['bar']['baz']['bat']['quux']['home']), var_export($messages, 1));
     $this->assertTrue(isset($messages['foo']['bar']['baz']['bat']['quux']['home']['notInArray']), var_export($messages, 1));
 }
开发者ID:lortnus,项目名称:zf1,代码行数:24,代码来源:FormTest.php

示例9: array

<?php

ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/path/to/zend/library');
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
$request = new Zend_Controller_Request_Http();
$view = new Zend_View();
/**
 * Example showing usage of array notation using setElementsBelongTo
 * on the form level, for shipping/billing addresses.
 */
$form = new Zend_Form();
$form->setView($view);
$form->addDecorator('Description', array('escape' => false, 'placement' => 'PREPEND'));
$form->setDescription('<h3>Using setElementsBelongTo</h3>');
$form->setElementsBelongTo('shipping');
$form->addElement('text', 'recipient', array('label' => 'Ship to', 'required' => true));
$form->addElement('text', 'address', array('label' => 'Address', 'required' => true));
$form->addElement('submit', 'submit', array('label' => 'Submit'));
if ($request->isPost()) {
    if ($form->isValid($request->getPost())) {
        echo 'Order placed, Thank you!';
    } else {
        echo 'You have errors in your form, please check';
    }
}
echo $form->render();
开发者ID:Tony133,项目名称:zf-web,代码行数:27,代码来源:Zend_Form_elementsBelongTo.php


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