本文整理汇总了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);
}
示例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);
}
示例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;
}
示例4: setOptions
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['maxGoals'])) {
$this->setMaxGoals($options['maxGoals']);
}
return $this;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}