Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow set Form::setPreferFormInputFilter via options #5015

Closed
wants to merge 2 commits into from

3 participants

@thestanislav

Allow set setPreferFormInputFilter options while building forms by FormFactory using form spec.

@Ocramius
Collaborator

@thestanislav can you add simple coverage for this one?

@thestanislav

This can be used to create forms via form factory

use Zend\Form\Factory;

$factory = new Factory();
$form    = $factory->createForm(array(
    'options' => array(
        'prefer_form_input_filter' => true
    ),
    'elements' => array(
        array(
            'spec' => array(
                'name' => 'name',
                'options' => array(
                    'label' => 'Your name',
                ),
                'type'  => 'Text',
            )
        ),
        array(
            'spec' => array(
                'type' => 'Zend\Form\Element\Email',
                'name' => 'email',
                'options' => array(
                    'label' => 'Your email address',
                )
            ),
        )
    ),
));
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#5015] Added unit tests
- Added tests to demonstrate that preferFormInputFilter flag can now be set via
  options and factory implementations.
d7eba45
@weierophinney

I added unit tests on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 24, 2013
  1. @thestanislav
  2. @thestanislav

    typo fix

    thestanislav authored
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 0 deletions.
  1. +20 −0 library/Zend/Form/Form.php
View
20 library/Zend/Form/Form.php
@@ -122,6 +122,26 @@ class Form extends Fieldset implements FormInterface
*/
protected $validationGroup;
+
+ /**
+ * Set options for a form. Accepted options are:
+ * - prefer_form_input_filter: is form input filter is preferred?
+ *
+ * @param array|Traversable $options
+ * @return Element|ElementInterface
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setOptions($options)
+ {
+ parent::setOptions($options);
+
+ if (isset($options['prefer_form_input_filter'])) {
+ $this->setPreferFormInputFilter($options['prefer_form_input_filter']);
+ }
+
+ return $this;
+ }
+
/**
* Add an element or fieldset
*
Something went wrong with that request. Please try again.