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); }
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); }
/** * 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; }
public function setOptions($options) { parent::setOptions($options); if (isset($options['maxGoals'])) { $this->setMaxGoals($options['maxGoals']); } return $this; }
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); }
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); }
/** * 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; }
/** * 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; }
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; }
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; }
/** * 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; }