Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[Form] add guess pattern #4077

Merged
merged 1 commit into from

9 participants

@ruian

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3766
Todo: -

Due to some trouble when rebase my previous PR i open a new one with Master merged
Refs PR: #3927

@stloyd stloyd commented on the diff
src/Symfony/Component/Form/FormFactory.php
@@ -306,7 +306,7 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
@stloyd
stloyd added a note

You should revert permission change.

@ruian
ruian added a note

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stloyd stloyd commented on the diff
src/Symfony/Component/Form/Tests/FormFactoryTest.php
@@ -491,6 +491,39 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence()
@stloyd
stloyd added a note

You should revert permission change.

@ruian
ruian added a note

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/Symfony/Component/Form/FormTypeGuesserInterface.php
@@ -44,13 +44,18 @@ function guessRequired($class, $property);
function guessMaxLength($class, $property);
/**
- * Returns a guess about the field's minimum length
+ * Returns a guess about the field's pattern
+ *
+ * - When you have a min value, you guess a min length of this min (LOW_CONFIDENCE) , lines below
+ * - If this value is a float type, this is wrong so you guess null with MEDIUM_CONFIDENCE to override the previous guess.
+ * Example:
+ * You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5)
+ * PR https://github.com/symfony/symfony/pull/3927
@stloyd
stloyd added a note

@see or @link before link could help a bit IMO.

@ruian
ruian added a note

Yep @link could be better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
CHANGELOG-2.1.md
@@ -277,6 +277,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
* [BC BREAK] renamed "field_*" theme blocks to "form_*" and "field_widget" to
"input"
* ValidatorTypeGuesser now guesses "collection" for array type constraint
+ * add guessPattern to guess which pattern to use inside the new HTML5 attribute `pattern=""`
@webmozart Collaborator

please rephrase to

added method `guessPattern` to FormTypeGuesserInterface to guess which pattern to use in the HTML5 attribute "pattern"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabpot
Owner

@vicb @bschussek ok for you?

@webmozart
Collaborator

please do also rephrase the commit message to something clearer, like

[Form] added method `guessPattern` to FormTypeGuesserInterface
@webmozart
Collaborator

Otherwise this looks good :)

@ruian

every changes done

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch ruian/guess_pattern (PR #4077)
Commits
-------

f7200e4 [Form] added method `guessPattern` to FormTypeGuesserInterface

Discussion
----------

[Form] add guess pattern

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3766
Todo: -

Due to some trouble when rebase my previous PR i open a new one with Master merged
Refs PR: #3927

---------------------------------------------------------------------------

by fabpot at 2012-04-23T10:25:57Z

@vicb @bschussek ok for you?

---------------------------------------------------------------------------

by bschussek at 2012-04-23T10:26:51Z

please do also rephrase the commit message to something clearer, like

    [Form] added method `guessPattern` to FormTypeGuesserInterface

---------------------------------------------------------------------------

by bschussek at 2012-04-23T10:27:35Z

Otherwise this looks good :)

---------------------------------------------------------------------------

by ruian at 2012-04-23T10:29:18Z

every changes done
27b4774
@fabpot fabpot merged commit f7200e4 into symfony:master
@Tobion Tobion commented on the diff
src/Symfony/Component/Form/FormTypeGuesserInterface.php
@@ -44,13 +44,18 @@ function guessRequired($class, $property);
function guessMaxLength($class, $property);
/**
- * Returns a guess about the field's minimum length
+ * Returns a guess about the field's pattern
+ *
+ * - When you have a min value, you guess a min length of this min (LOW_CONFIDENCE) , lines below
+ * - If this value is a float type, this is wrong so you guess null with MEDIUM_CONFIDENCE to override the previous guess.
+ * Example:
+ * You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5)
+ * @link https://github.com/symfony/symfony/pull/3927
@Tobion Collaborator
Tobion added a note

this description is very abstruse and the link doesn't belong here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lsmith77 lsmith77 commented on the diff
CHANGELOG-2.1.md
@@ -277,6 +277,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
* [BC BREAK] renamed "field_*" theme blocks to "form_*" and "field_widget" to
"input"
* ValidatorTypeGuesser now guesses "collection" for array type constraint
+ * added method `guessPattern` to FormTypeGuesserInterface to guess which pattern to use in the HTML5 attribute "pattern"
@lsmith77 Collaborator

why is dropping guessMinLength() not noted as a BC break?

@ruian
ruian added a note

Maybe i can make a PR to fixe this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@marcospassos

Thanks!

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch bschussek/issue4077 (PR #4085)
Commits
-------

d9e142b [Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser

Discussion
----------

[Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue4077)

This is a follow-up PR to #4077 (see comments in #3927 for reference).
c2a426e
@vendethiel
Collaborator

it is not trailing (as it is not at the end of the line) but there is indeed an extra space here

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch lavoiesl/master (PR #4522)
Commits
-------

6f9eda9 [Form][Validator] Fixed generation of HTML5 pattern attribute based on Assert\Regex to remove delimiters.

Discussion
----------

[Form][Validator] Fixed generation of HTML5 pattern attribute based on Assert\Regex by removing delimiters or using a new option: htmlPattern.

Hopefully, this time is the good one…

* Fixes: [#3766, #4077, #4513, #4520, #4521]
* Bug fix: yes
* Feature addition: yes
* BC break: no
* Symfony2 tests pass: yes

In Issue #3766, it was asked that Assert\Regex generates HTML5 pattern attribute.
It was done in PR #4077, but the generated Regex is in delimited format which is not supported by HTML5.

Hence, `/[a-z]+/` would be converted to `[a-z]+`.
If flags are specified like in `/[a-z]+/i`, it cannot be converted and pattern validation will be disabled client-side. If is however now possible, using a new option, `htmlPattern`, to specify the pattern you want to be used.

Example:

```php
<?php
/**
 * @Assert\Regex(pattern="/^[0-9]+[a-z]*$/i", htmlPattern="^[0-9]+[a-zA-Z]*$")
 */
private $civic_number;
```

**Note**: [Documentation](http://symfony.com/doc/current/reference/constraints/Regex.html) should be updated accordingly.

---------------------------------------------------------------------------

by lavoiesl at 2012-06-08T15:45:17Z

God, I just found out you can "add more commits to this pull request by pushing to the master branch on lavoiesl/symfony"…

---------------------------------------------------------------------------

by travisbot at 2012-06-08T15:50:31Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1568634) (merged 2d767b41 into b84b46b).

---------------------------------------------------------------------------

by petajaros at 2012-07-04T14:23:16Z

Anything new about this issue?

---------------------------------------------------------------------------

by lavoiesl at 2012-07-04T16:25:43Z

Alright, tests are passing using `phpunit -c phpunit.xml.dist --filter 'RegexValidatorTest'`. @travisbot reports errors because he can’t even start the tests due to dependencies, which is not related

---------------------------------------------------------------------------

by vicb at 2012-07-04T16:31:13Z

It should be ready to merge when you have taken the last comments into account. thanks.

---------------------------------------------------------------------------

by lavoiesl at 2012-07-04T16:39:05Z

So it seems this PR will finally pass, thanks a lot.

---------------------------------------------------------------------------

by vicb at 2012-07-04T17:03:35Z

Thank you for this PR and the changes.

---------------------------------------------------------------------------

by fabpot at 2012-07-04T17:10:20Z

@lavoiesl Can you squash your commits before I merge? Thanks.

---------------------------------------------------------------------------

by lavoiesl at 2012-07-04T17:25:18Z

There. I also left trace of some commits I did.

Thanks
1cff950
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch ruian/guess_pattern (PR #4077)
Commits
-------

f7200e4 [Form] added method `guessPattern` to FormTypeGuesserInterface

Discussion
----------

[Form] add guess pattern

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3766
Todo: -

Due to some trouble when rebase my previous PR i open a new one with Master merged
Refs PR: #3927

---------------------------------------------------------------------------

by fabpot at 2012-04-23T10:25:57Z

@vicb @bschussek ok for you?

---------------------------------------------------------------------------

by bschussek at 2012-04-23T10:26:51Z

please do also rephrase the commit message to something clearer, like

    [Form] added method `guessPattern` to FormTypeGuesserInterface

---------------------------------------------------------------------------

by bschussek at 2012-04-23T10:27:35Z

Otherwise this looks good :)

---------------------------------------------------------------------------

by ruian at 2012-04-23T10:29:18Z

every changes done
cb419c0
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch bschussek/issue4077 (PR #4085)
Commits
-------

d9e142b [Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser

Discussion
----------

[Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue4077)

This is a follow-up PR to #4077 (see comments in #3927 for reference).
2511b2f
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch lavoiesl/master (PR #4522)
Commits
-------

6f9eda9 [Form][Validator] Fixed generation of HTML5 pattern attribute based on Assert\Regex to remove delimiters.

Discussion
----------

[Form][Validator] Fixed generation of HTML5 pattern attribute based on Assert\Regex by removing delimiters or using a new option: htmlPattern.

Hopefully, this time is the good one…

* Fixes: [#3766, #4077, #4513, #4520, #4521]
* Bug fix: yes
* Feature addition: yes
* BC break: no
* Symfony2 tests pass: yes

In Issue #3766, it was asked that Assert\Regex generates HTML5 pattern attribute.
It was done in PR #4077, but the generated Regex is in delimited format which is not supported by HTML5.

Hence, `/[a-z]+/` would be converted to `[a-z]+`.
If flags are specified like in `/[a-z]+/i`, it cannot be converted and pattern validation will be disabled client-side. If is however now possible, using a new option, `htmlPattern`, to specify the pattern you want to be used.

Example:

```php
<?php
/**
 * @Assert\Regex(pattern="/^[0-9]+[a-z]*$/i", htmlPattern="^[0-9]+[a-zA-Z]*$")
 */
private $civic_number;
```

**Note**: [Documentation](http://symfony.com/doc/current/reference/constraints/Regex.html) should be updated accordingly.

---------------------------------------------------------------------------

by lavoiesl at 2012-06-08T15:45:17Z

God, I just found out you can "add more commits to this pull request by pushing to the master branch on lavoiesl/symfony"…

---------------------------------------------------------------------------

by travisbot at 2012-06-08T15:50:31Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1568634) (merged 2d767b41 into b84b46b).

---------------------------------------------------------------------------

by petajaros at 2012-07-04T14:23:16Z

Anything new about this issue?

---------------------------------------------------------------------------

by lavoiesl at 2012-07-04T16:25:43Z

Alright, tests are passing using `phpunit -c phpunit.xml.dist --filter 'RegexValidatorTest'`. @travisbot reports errors because he can’t even start the tests due to dependencies, which is not related

---------------------------------------------------------------------------

by vicb at 2012-07-04T16:31:13Z

It should be ready to merge when you have taken the last comments into account. thanks.

---------------------------------------------------------------------------

by lavoiesl at 2012-07-04T16:39:05Z

So it seems this PR will finally pass, thanks a lot.

---------------------------------------------------------------------------

by vicb at 2012-07-04T17:03:35Z

Thank you for this PR and the changes.

---------------------------------------------------------------------------

by fabpot at 2012-07-04T17:10:20Z

@lavoiesl Can you squash your commits before I merge? Thanks.

---------------------------------------------------------------------------

by lavoiesl at 2012-07-04T17:25:18Z

There. I also left trace of some commits I did.

Thanks
7b3528d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 23, 2012
  1. @ruian

    [Form] added method `guessPattern` to FormTypeGuesserInterface

    julien.galenski authored ruian committed
    rephrase changelog
This page is out of date. Refresh to see the latest.
View
1  CHANGELOG-2.1.md
@@ -277,6 +277,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
* [BC BREAK] renamed "field_*" theme blocks to "form_*" and "field_widget" to
"input"
* ValidatorTypeGuesser now guesses "collection" for array type constraint
+ * added method `guessPattern` to FormTypeGuesserInterface to guess which pattern to use in the HTML5 attribute "pattern"
@lsmith77 Collaborator

why is dropping guessMinLength() not noted as a BC break?

@ruian
ruian added a note

Maybe i can make a PR to fixe this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
### HttpFoundation
View
2  src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
@@ -115,7 +115,7 @@ public function guessMaxLength($class, $property)
/**
* {@inheritDoc}
*/
- public function guessMinLength($class, $property)
+ public function guessPattern($class, $property)
{
$ret = $this->getMetadata($class);
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
View
2  src/Symfony/Bridge/Propel1/Form/PropelTypeGuesser.php
@@ -124,7 +124,7 @@ public function guessMaxLength($class, $property)
/**
* {@inheritDoc}
*/
- public function guessMinLength($class, $property)
+ public function guessPattern($class, $property)
{
if ($column = $this->getColumn($class, $property)) {
switch ($column->getType()) {
View
4 src/Symfony/Bridge/Propel1/Tests/Form/PropelTypeGuesserTest.php
@@ -46,14 +46,14 @@ public function testGuessMaxLengthWithFloat()
public function testGuessMinLengthWithText()
{
- $value = $this->guesser->guessMinLength(self::CLASS_NAME, 'value');
+ $value = $this->guesser->guessPattern(self::CLASS_NAME, 'value');
$this->assertNull($value);
}
public function testGuessMinLengthWithFloat()
{
- $value = $this->guesser->guessMinLength(self::CLASS_NAME, 'price');
+ $value = $this->guesser->guessPattern(self::CLASS_NAME, 'price');
$this->assertNotNull($value);
$this->assertNull($value->getValue());
View
31 src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php 100644 → 100755
@@ -68,12 +68,12 @@ public function guessMaxLength($class, $property)
/**
* {@inheritDoc}
*/
- public function guessMinLength($class, $property)
+ public function guessPattern($class, $property)
{
$guesser = $this;
return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) {
- return $guesser->guessMinLengthForConstraint($constraint);
+ return $guesser->guessPatternForConstraint($constraint);
});
}
@@ -205,32 +205,35 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
}
/**
- * Guesses a field's minimum length based on the given constraint
- *
+ * Guesses a field's pattern based on the given constraint
+ *
* @param Constraint $constraint The constraint to guess for
*
- * @return Guess The guess for the minimum length
+ * @return Guess The guess for the pattern
*/
- public function guessMinLengthForConstraint(Constraint $constraint)
+ public function guessPatternForConstraint(Constraint $constraint)
{
switch (get_class($constraint)) {
case 'Symfony\Component\Validator\Constraints\MinLength':
- return new ValueGuess($constraint->limit, Guess::HIGH_CONFIDENCE);
+ return new ValueGuess(sprintf('.{%s,}', (string) $constraint->limit), Guess::LOW_CONFIDENCE);
case 'Symfony\Component\Validator\Constraints\SizeLength':
- return new ValueGuess($constraint->min, Guess::HIGH_CONFIDENCE);
+ return new ValueGuess(sprintf('.{%s,%s}', (string) $constraint->min, (string) $constraint->max), Guess::LOW_CONFIDENCE);
+
+ case 'Symfony\Component\Validator\Constraints\Regex':
+ return new ValueGuess($constraint->pattern, Guess::HIGH_CONFIDENCE );
+
+ case 'Symfony\Component\Validator\Constraints\Min':
+ return new ValueGuess(sprintf('.{%s,}', strlen((string) $constraint->limit)), Guess::LOW_CONFIDENCE);
+ case 'Symfony\Component\Validator\Constraints\Size':
+ return new ValueGuess(sprintf('.{%s,%s}', strlen((string) $constraint->min), strlen((string) $constraint->max)), Guess::LOW_CONFIDENCE);
+
case 'Symfony\Component\Validator\Constraints\Type':
if (in_array($constraint->type, array('double', 'float', 'numeric', 'real'))) {
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
break;
-
- case 'Symfony\Component\Validator\Constraints\Min':
- return new ValueGuess(strlen((string) $constraint->limit), Guess::LOW_CONFIDENCE);
-
- case 'Symfony\Component\Validator\Constraints\Size':
- return new ValueGuess(strlen((string) $constraint->min), Guess::LOW_CONFIDENCE);
}
}
View
15 src/Symfony/Component/Form/FormFactory.php
@@ -306,7 +306,7 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
/**
* Returns a form builder for a property of a class.
*
- * If any of the 'max_length', 'required' and type options can be guessed,
+ * If any of the 'max_length', 'required', 'pattern' and type options can be guessed,
* and are not provided in the options argument, the guessed value is used.
*
* @param string $class The fully qualified class name
@@ -327,27 +327,26 @@ public function createBuilderForProperty($class, $property, $data = null, array
$typeGuess = $this->guesser->guessType($class, $property);
$maxLengthGuess = $this->guesser->guessMaxLength($class, $property);
- $minLengthGuess = $this->guesser->guessMinLength($class, $property);
$requiredGuess = $this->guesser->guessRequired($class, $property);
+ $patternGuess = $this->guesser->guessPattern($class, $property);
$type = $typeGuess ? $typeGuess->getType() : 'text';
$maxLength = $maxLengthGuess ? $maxLengthGuess->getValue() : null;
- $minLength = $minLengthGuess ? $minLengthGuess->getValue() : null;
- $minLength = $minLength ?: 0;
+ $pattern = $patternGuess ? $patternGuess->getValue() : null;
if (null !== $maxLength) {
$options = array_merge(array('max_length' => $maxLength), $options);
}
- if ($minLength > 0) {
- $options = array_merge(array('pattern' => '.{'.$minLength.','.$maxLength.'}'), $options);
- }
-
if ($requiredGuess) {
$options = array_merge(array('required' => $requiredGuess->getValue()), $options);
}
+ if (null !== $pattern) {
+ $options = array_merge(array('pattern' => $pattern), $options);
+ }
+
// user options may override guessed options
if ($typeGuess) {
$options = array_merge($typeGuess->getOptions(), $options);
View
16 src/Symfony/Component/Form/FormTypeGuesserChain.php
@@ -40,6 +40,9 @@ public function __construct(array $guessers)
}
}
+ /**
+ * {@inheritDoc}
+ */
public function guessType($class, $property)
{
return $this->guess(function ($guesser) use ($class, $property) {
@@ -47,6 +50,9 @@ public function guessType($class, $property)
});
}
+ /**
+ * {@inheritDoc}
+ */
public function guessRequired($class, $property)
{
return $this->guess(function ($guesser) use ($class, $property) {
@@ -54,6 +60,9 @@ public function guessRequired($class, $property)
});
}
+ /**
+ * {@inheritDoc}
+ */
public function guessMaxLength($class, $property)
{
return $this->guess(function ($guesser) use ($class, $property) {
@@ -61,10 +70,13 @@ public function guessMaxLength($class, $property)
});
}
- public function guessMinLength($class, $property)
+ /**
+ * {@inheritDoc}
+ */
+ public function guessPattern($class, $property)
{
return $this->guess(function ($guesser) use ($class, $property) {
- return $guesser->guessMinLength($class, $property);
+ return $guesser->guessPattern($class, $property);
});
}
View
13 src/Symfony/Component/Form/FormTypeGuesserInterface.php
@@ -44,13 +44,18 @@ function guessRequired($class, $property);
function guessMaxLength($class, $property);
/**
- * Returns a guess about the field's minimum length
+ * Returns a guess about the field's pattern
+ *
+ * - When you have a min value, you guess a min length of this min (LOW_CONFIDENCE) , lines below
+ * - If this value is a float type, this is wrong so you guess null with MEDIUM_CONFIDENCE to override the previous guess.
+ * Example:
+ * You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5)
+ * @link https://github.com/symfony/symfony/pull/3927
@Tobion Collaborator
Tobion added a note

this description is very abstruse and the link doesn't belong here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
*
* @param string $class The fully qualified class name
* @param string $property The name of the property to guess for
*
- * @return Guess A guess for the field's minimum length
+ * @return Guess A guess for the field's required pattern
*/
- function guessMinLength($class, $property);
-
+ function guessPattern($class, $property);
}
View
57 src/Symfony/Component/Form/Tests/FormFactoryTest.php
@@ -491,6 +491,39 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence()
$this->assertEquals('builderInstance', $builder);
}
+ public function testCreateBuilderUsesPatternIfFound()
+ {
+ $this->guesser1->expects($this->once())
+ ->method('guessPattern')
+ ->with('Application\Author', 'firstName')
+ ->will($this->returnValue(new ValueGuess(
+ '/[a-z]/',
+ Guess::MEDIUM_CONFIDENCE
+ )));
+
+ $this->guesser2->expects($this->once())
+ ->method('guessPattern')
+ ->with('Application\Author', 'firstName')
+ ->will($this->returnValue(new ValueGuess(
+ '/[a-zA-Z]/',
+ Guess::HIGH_CONFIDENCE
+ )));
+
+ $factory = $this->createMockFactory(array('createNamedBuilder'));
+
+ $factory->expects($this->once())
+ ->method('createNamedBuilder')
+ ->with('text', 'firstName', null, array('pattern' => '/[a-zA-Z]/'))
+ ->will($this->returnValue('builderInstance'));
+
+ $builder = $factory->createBuilderForProperty(
+ 'Application\Author',
+ 'firstName'
+ );
+
+ $this->assertEquals('builderInstance', $builder);
+ }
+
public function testCreateNamedBuilderFromParentBuilder()
{
$type = new FooType();
@@ -541,18 +574,18 @@ public function testUnknownOption()
$factory->createNamedBuilder($type, "text", "value", array("unknown" => "opt"));
}
- public function testFormTypeCreatesDefaultValueForEmptyDataOption()
- {
- $factory = new FormFactory(array(new \Symfony\Component\Form\Extension\Core\CoreExtension()));
-
- $form = $factory->createNamedBuilder(new AuthorType(), 'author')->getForm();
- $form->bind(array('firstName' => 'John', 'lastName' => 'Smith'));
-
- $author = new Author();
- $author->firstName = 'John';
- $author->setLastName('Smith');
-
- $this->assertEquals($author, $form->getData());
+ public function testFieldTypeCreatesDefaultValueForEmptyDataOption()
+ {
+ $factory = new FormFactory(array(new \Symfony\Component\Form\Extension\Core\CoreExtension()));
+
+ $form = $factory->createNamedBuilder(new AuthorType(), 'author')->getForm();
+ $form->bind(array('firstName' => 'John', 'lastName' => 'Smith'));
+
+ $author = new Author();
+ $author->firstName = 'John';
+ $author->setLastName('Smith');
+
+ $this->assertEquals($author, $form->getData());
}
private function createMockFactory(array $methods = array())
Something went wrong with that request. Please try again.