예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('widget' => $options['widget'], 'with_seconds' => $options['with_seconds']));
     if ('single_text' === $options['widget']) {
         $view->setVar('type', 'time');
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('allow_add' => $options['allow_add'], 'allow_delete' => $options['allow_delete']));
     if ($form->getConfig()->hasAttribute('prototype')) {
         $view->setVar('prototype', $form->getConfig()->getAttribute('prototype')->createView($view));
     }
 }
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     if (!is_array($options['widget_addon'])) {
         throw new CreationException("The 'widget_addon' option must be an array");
     } else {
         $defaults = $this->getDefaultOptions($options);
         $options['widget_addon'] = array_merge($defaults['widget_addon'], $options['widget_addon']);
     }
     if (in_array('percent', $view->getVar('types'))) {
         if ($options['widget_addon']['text'] === null && $options['widget_addon']['icon'] === null) {
             $options['widget_addon']['text'] = '%';
         }
         if ($options['widget_addon']['type'] === null) {
             $options['widget_addon']['type'] = 'append';
         }
     }
     if (in_array('money', $view->getVar('types'))) {
         if ($options['widget_addon']['type'] === null) {
             $options['widget_addon']['type'] = 'prepend';
         }
     }
     if (($options['widget_addon']['text'] !== null || $options['widget_addon']['icon'] !== null) && $options['widget_addon']['type'] === null) {
         throw new \Exception('You must provide a "type" for widget_addon');
     }
     $view->addVars(array('widget_control_group' => $options['widget_control_group'], 'widget_controls' => $options['widget_controls'], 'widget_addon' => $options['widget_addon'], 'widget_prefix' => $options['widget_prefix'], 'widget_suffix' => $options['widget_suffix'], 'widget_type' => $options['widget_type'], 'widget_control_group_attr' => $options['widget_control_group_attr'], 'widget_controls_attr' => $options['widget_controls_attr']));
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('multiple' => $options['multiple'], 'expanded' => $options['expanded'], 'preferred_choices' => $options['choice_list']->getPreferredViews(), 'choices' => $options['choice_list']->getRemainingViews(), 'separator' => '-------------------', 'empty_value' => null));
     // Check if the choices already contain the empty value
     // Only add the empty value option if this is not the case
     if (0 === count($options['choice_list']->getIndicesForValues(array('')))) {
         $view->setVar('empty_value', $options['empty_value']);
     }
     if ($options['multiple'] && !$options['expanded']) {
         // Add "[]" to the name in case a select tag with multiple options is
         // displayed. Otherwise only one of the selected options is sent in the
         // POST request.
         $view->setVar('full_name', $view->getVar('full_name') . '[]');
     }
 }
예제 #5
0
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $fingerprint = null;
     if ($options['keep_value'] && $this->session->has($this->key . '_fingerprint')) {
         $fingerprint = $this->session->get($this->key . '_fingerprint');
     }
     $generator = new CaptchaGenerator($this->generateCaptchaValue(), $options['image_folder'], $options['web_path'], $options['gc_freq'], $options['expiration'], $options['font'], $fingerprint, $options['quality']);
     if ($options['as_file']) {
         $captchaCode = $generator->getFile($options['width'], $options['height']);
     } else {
         $captchaCode = $generator->getCode($options['width'], $options['height']);
     }
     if ($options['keep_value']) {
         $this->session->set($this->key . '_fingerprint', $generator->getFingerprint());
     }
     $view->addVars(array('captcha_width' => $options['width'], 'captcha_height' => $options['height'], 'captcha_code' => $captchaCode, 'value' => ''));
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $name = $form->getName();
     $blockName = $options['block_name'] ?: $form->getName();
     $readOnly = $options['read_only'];
     $translationDomain = $options['translation_domain'];
     if ($view->hasParent()) {
         if ('' === $name) {
             throw new FormException('Form node with empty name can be used only as root form node.');
         }
         $parentView = $view->getParent();
         if ('' !== ($parentFullName = $parentView->getVar('full_name'))) {
             $id = sprintf('%s_%s', $parentView->getVar('id'), $name);
             $fullName = sprintf('%s[%s]', $parentFullName, $name);
             $fullBlockName = sprintf('%s_%s', $parentView->getVar('full_block_name'), $blockName);
         } else {
             $id = $name;
             $fullName = $name;
             $fullBlockName = '_' . $blockName;
         }
         // Complex fields are read-only if they themselves or their parents are.
         if (!$readOnly) {
             $readOnly = $parentView->getVar('read_only');
         }
         if (!$translationDomain) {
             $translationDomain = $parentView->getVar('translation_domain');
         }
     } else {
         $id = $name;
         $fullName = $name;
         $fullBlockName = '_' . $blockName;
         // Strip leading underscores and digits. These are allowed in
         // form names, but not in HTML4 ID attributes.
         // http://www.w3.org/TR/html401/struct/global.html#adef-id
         $id = ltrim($id, '_0123456789');
     }
     $types = array();
     for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) {
         array_unshift($types, $type->getName());
     }
     if (!$translationDomain) {
         $translationDomain = 'messages';
     }
     $view->addVars(array('form' => $view, 'id' => $id, 'name' => $name, 'full_name' => $fullName, 'full_block_name' => $fullBlockName, 'read_only' => $readOnly, 'errors' => $form->getErrors(), 'valid' => $form->isBound() ? $form->isValid() : true, 'value' => $form->getViewData(), 'disabled' => $form->isDisabled(), 'required' => $form->isRequired(), 'max_length' => $options['max_length'], 'pattern' => $options['pattern'], 'size' => null, 'label' => $options['label'], 'multipart' => false, 'attr' => $options['attr'], 'label_attr' => $options['label_attr'], 'compound' => $form->getConfig()->getCompound(), 'types' => $types, 'translation_domain' => $translationDomain));
 }
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     if ($options['widget_add_btn'] != null && !is_array($options['widget_add_btn'])) {
         throw new FormException('The "widget_add_btn" option must be an "array".');
     } elseif ($options['widget_add_btn'] != null) {
         if (isset($options['widget_add_btn']['attr']) && !is_array($options['widget_add_btn']['attr'])) {
             throw new FormException('The "widget_add_btn.attr" option must be an "array".');
         }
         if (!isset($options['widget_add_btn']['attr'])) {
             $options['widget_add_btn']['attr'] = $this->options['widget_add_btn']['attr'];
         }
         if (!isset($options['widget_add_btn']['label']) && !isset($options['widget_add_btn']['icon'])) {
             throw new FormException('Provide either "icon" or "label" to "widget_add_btn"');
         }
         if (!isset($options['widget_add_btn']['icon']) && $this->options['widget_add_btn']['icon'] != null) {
             $options['widget_add_btn']['icon'] = $this->options['widget_add_btn']['icon'];
         }
     }
     if ($options['widget_remove_btn'] != null && !is_array($options['widget_remove_btn'])) {
         throw new FormException('The "widget_remove_btn" option must be an "array".');
     } elseif ($options['widget_remove_btn'] != null) {
         if (isset($options['widget_remove_btn']) && !is_array($options['widget_remove_btn'])) {
             throw new FormException('The "widget_remove_btn" option must be an "array".');
         }
         if (!isset($options['widget_remove_btn']['attr'])) {
             $options['widget_remove_btn']['attr'] = $this->options['widget_remove_btn']['attr'];
         }
         if (!isset($options['widget_remove_btn']['label']) && !isset($options['widget_remove_btn']['icon'])) {
             throw new FormException('Provide either "icon" or "label" to "widget_remove_btn"');
         }
         if (!isset($options['widget_remove_btn']['icon']) && $this->options['widget_remove_btn']['icon'] != null) {
             $options['widget_remove_btn']['icon'] = $this->options['widget_remove_btn']['icon'];
         }
     }
     $view->addVars(array('widget_add_btn' => $options['widget_add_btn'], 'widget_remove_btn' => $options['widget_remove_btn']));
 }
예제 #8
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('suggestions' => $options['suggestions'], 'multiple' => $options['multiple'], 'route_name' => $options['route_name']));
 }
예제 #9
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('type' => 'file', 'value' => ''));
 }
예제 #10
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('value' => $options['value'], 'checked' => null !== $form->getViewData()));
 }
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('render_fieldset' => $options['render_fieldset'], 'show_legend' => $options['show_legend'], 'show_child_legend' => $options['show_child_legend'], 'label_render' => $options['label_render'], 'render_required_asterisk' => $options['render_required_asterisk']));
 }
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('error_type' => $options['error_type'], 'error_delay' => $options['error_delay']));
 }
예제 #13
0
파일: CaptchaType.php 프로젝트: hykz/Depot
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $captcha = $form->getAttribute('captcha');
     $view->addVars(array('value' => '', 'position' => $form->getAttribute('position'), 'src' => $captcha->getBase64($form->getAttribute('format')), 'width' => $captcha->getWidth(), 'height' => $captcha->getHeight()));
 }
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('help_inline' => $options['help_inline'], 'help_block' => $options['help_block'], 'help_label' => $options['help_label']));
 }
예제 #15
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('public_key' => $this->publicKey, 'server' => $this->serverUrl, 'configs' => $options['configs']));
 }
예제 #16
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $view->addVars(array('configs' => array('elements' => array()), 'map' => $options['map']));
 }