當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Fieldset::setOptions方法代碼示例

本文整理匯總了PHP中Zend\Form\Fieldset::setOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Fieldset::setOptions方法的具體用法?PHP Fieldset::setOptions怎麽用?PHP Fieldset::setOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\Fieldset的用法示例。


在下文中一共展示了Fieldset::setOptions方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($name = 'register-form', CaptchaOptions $options, $role = 'recruiter')
 {
     parent::__construct($name, []);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $fieldset = new Fieldset('register');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
     $fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email'), 'attributes' => ['required' => true]));
     $fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => $role)));
     $this->add($fieldset);
     $mode = $options->getMode();
     if (in_array($mode, [CaptchaOptions::RE_CAPTCHA, CaptchaOptions::IMAGE])) {
         if ($mode == CaptchaOptions::IMAGE) {
             $captcha = new Image($options->getImage());
         } elseif ($mode == CaptchaOptions::RE_CAPTCHA) {
             $captcha = new ReCaptcha($options->getReCaptcha());
         }
         if (!empty($captcha)) {
             $this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
         }
     }
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
     $this->add($buttons);
 }
開發者ID:utrenkner,項目名稱:YAWIK,代碼行數:27,代碼來源:Register.php

示例2: __construct

 public function __construct($name = 'register-form', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $fieldset = new Fieldset('register');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
     $fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email')));
     $fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => User::ROLE_RECRUITER)));
     $this->add($fieldset);
     if (($captchaOptions = $this->getOption('captcha')) && !empty($captchaOptions['use'])) {
         if ($captchaOptions['use'] === 'image' && !empty($captchaOptions['image'])) {
             $captcha = new Image($captchaOptions['image']);
         } elseif ($captchaOptions['use'] === 'reCaptcha' && !empty($captchaOptions['reCaptcha'])) {
             $captcha = new ReCaptcha($captchaOptions['reCaptcha']);
         }
         if (!empty($captcha)) {
             $this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
         }
     }
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
     $this->add($buttons);
 }
開發者ID:vfulco,項目名稱:YAWIK,代碼行數:26,代碼來源:Register.php

示例3: setOptions

 /**
  * Set options for a fieldset. Accepted options are:
  * - input_filter_spec: specification to be returned by getInputFilterSpecification
  *
  * @param  array|Traversable $options
  * @return Element|ElementInterface
  * @throws Exception\InvalidArgumentException
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['input_filter_spec'])) {
         $this->setInputFilterSpecification($options['input_filter_spec']);
     }
     return $this;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:16,代碼來源:InputFilterProviderFieldset.php

示例4: setOptions

 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['maxGoals'])) {
         $this->setMaxGoals($options['maxGoals']);
     }
     return $this;
 }
開發者ID:0ida,項目名稱:fussi,代碼行數:8,代碼來源:Game.php

示例5: __construct

 public function __construct($name = 'login-form', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-inline');
     $fieldset = new Fieldset('credentials');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('name' => 'login', 'options' => array('id' => 'login', 'label' => 'Login name')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('id' => 'credential', 'label' => 'Password')));
     $this->add($fieldset);
     $buttons = new \Core\Form\ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
     $this->add($buttons);
 }
開發者ID:utrenkner,項目名稱:YAWIK,代碼行數:14,代碼來源:Login.php

示例6: init

 public function init()
 {
     $this->setName('login-form');
     $this->setAttribute('data-handle-by', 'native');
     $fieldset = new Fieldset('credentials');
     //$fieldset->setLabel('Enter your credentials');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password')));
     $this->add($fieldset);
     $buttons = new \Core\Form\ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
     $this->add($buttons);
 }
開發者ID:bitrecruiter,項目名稱:CrossApplicantManager,代碼行數:14,代碼來源:Login.php

示例7: setOptions

 /**
  * Accepted options for Collection:
  * - target_element: an array or element used in the collection
  * - count: number of times the element is added initially
  * - allow_add: if set to true, elements can be added to the form dynamically (using JavaScript)
  * - should_create_template: if set to true, a template is generated (inside a <span>)
  * - template_placeholder: placeholder used in the data template
  *
  * @param array|\Traversable $options
  * @return Collection
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['target_element'])) {
         $this->setTargetElement($options['target_element']);
     }
     if (isset($options['count'])) {
         $this->setCount($options['count']);
     }
     if (isset($options['allow_add'])) {
         $this->setAllowAdd($options['allow_add']);
     }
     if (isset($options['should_create_template'])) {
         $this->setShouldCreateTemplate($options['should_create_template']);
     }
     if (isset($options['template_placeholder'])) {
         $this->setTemplatePlaceholder($options['template_placeholder']);
     }
     return $this;
 }
開發者ID:robertodormepoco,項目名稱:zf2,代碼行數:31,代碼來源:Collection.php

示例8: setOptions

 /**
  * Set options for a form. Accepted options are:
  * - prefer_form_input_filter: is form input filter is preferred?
  *
  * @param  array|Traversable $options
  * @return self
  * @throws Exception\InvalidArgumentException
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['prefer_form_input_filter'])) {
         $this->setPreferFormInputFilter($options['prefer_form_input_filter']);
     }
     if (isset($options['use_input_filter_defaults'])) {
         $this->setUseInputFilterDefaults($options['use_input_filter_defaults']);
     }
     return $this;
 }
開發者ID:Flesh192,項目名稱:magento,代碼行數:19,代碼來源:Form.php

示例9: setOptions

 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['fetch_url'])) {
         $this->setFetchUrl($options['fetch_url']);
     }
     if (isset($options['preview_url'])) {
         $this->setPreviewUrl($options['preview_url']);
     }
     if (isset($options['profiles'])) {
         foreach ($options['profiles'] as $name => $options) {
             $this->addProfileButton($name, $options);
         }
     }
     return $this;
 }
開發者ID:cross-solution,項目名稱:yawik,代碼行數:16,代碼來源:SocialProfilesFieldset.php

示例10: setOptions

 public function setOptions($options)
 {
     parent::setOptions($options);
     $options = $this->options;
     // assure array
     if ($this->has('text')) {
         $textElement = $this->get('text');
         if (isset($options['text_placeholder'])) {
             $textElement->setAttribute('placeholder', $options['text_placeholder']);
         }
         if (isset($options['text_span'])) {
             $textElement->setOption('span', $options['text_span']);
         }
         if (isset($options['text_label'])) {
             $textElement->setLabel($options['text_label']);
         }
     }
     return $this;
 }
開發者ID:cross-solution,項目名稱:yawik,代碼行數:19,代碼來源:TextSearchFormFieldset.php

示例11: setOptions

 /**
  * Accepted options for Collection:
  * - target_element: an array or element used in the collection
  * - count: number of times the element is added initially
  * - allow_add: if set to true, elements can be added to the form dynamically (using JavaScript)
  * - allow_remove: if set to true, elements can be removed to the form
  * - should_create_template: if set to true, a template is generated (inside a <span>)
  * - template_placeholder: placeholder used in the data template
  *
  * @param array|Traversable $options
  * @return Collection
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['target_element'])) {
         $this->setTargetElement($options['target_element']);
     }
     if (isset($options['count'])) {
         $this->setCount($options['count']);
     }
     if (isset($options['allow_add'])) {
         $this->setAllowAdd($options['allow_add']);
     }
     if (isset($options['allow_remove'])) {
         $this->setAllowRemove($options['allow_remove']);
     }
     if (isset($options['should_create_template'])) {
         $this->setShouldCreateTemplate($options['should_create_template']);
     }
     if (isset($options['template_placeholder'])) {
         $this->setTemplatePlaceholder($options['template_placeholder']);
     }
     if (isset($options['create_new_objects'])) {
         $this->setCreateNewObjects($options['create_new_objects']);
     }
     if (isset($options['key_names']) && is_array($options['key_names'])) {
         $this->setKeyNames(array_values($options['key_names']));
     }
     if (isset($options['labels']) && is_array($options['labels'])) {
         $this->setLabels(array_values($options['labels']));
     }
     return $this;
 }
開發者ID:serus22,項目名稱:zend-form,代碼行數:44,代碼來源:Collection.php


注:本文中的Zend\Form\Fieldset::setOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。