Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DomCrawler][Feature][DX] Add Form::getName() method #31959

Merged
merged 1 commit into from Jun 14, 2019

Conversation

Projects
None yet
5 participants
@JustBlackBird
Copy link
Contributor

commented Jun 8, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets None
License MIT
Doc PR symfony/symfony-docs#11705

The PR adds Symfony\Component\DomCrawler\Form::getName method.

The method is actually a syntax sugar but can improve DX when dealing with tests. For example, in the snippet

$client = static::createClient();
$crawler = $client->request('GET', '/post/hello-world');
$form = $crawler->selectButton('submit')->form();

$form['my_form[name]'] = 'Fabien';
$form['my_form[subject]'] = 'Symfony rocks!';

the prefix in field name (my_form) is form name, which is generated by Symfony automatically. The method, added in the PR helps to get that name in a most obvious way.

@JustBlackBird JustBlackBird changed the title [DomCrawler][Feature] Add Form::getName() method [DomCrawler][Feature][DX] Add Form::getName() method Jun 8, 2019

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Jun 9, 2019

I like the idea !

@nicolas-grekas nicolas-grekas added this to the next milestone Jun 9, 2019

Show resolved Hide resolved src/Symfony/Component/DomCrawler/Form.php Outdated
Show resolved Hide resolved src/Symfony/Component/DomCrawler/Form.php Outdated
@fabpot

fabpot approved these changes Jun 14, 2019

@fabpot fabpot force-pushed the JustBlackBird:dom-crawler-form-name branch from 8095c37 to ff53cb4 Jun 14, 2019

@fabpot

This comment has been minimized.

Copy link
Member

commented Jun 14, 2019

Thank you @JustBlackBird.

@fabpot fabpot merged commit ff53cb4 into symfony:4.4 Jun 14, 2019

1 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Jun 14, 2019

feature #31959 [DomCrawler][Feature][DX] Add Form::getName() method (…
…JustBlackBird)

This PR was squashed before being merged into the 4.4 branch (closes #31959).

Discussion
----------

[DomCrawler][Feature][DX] Add Form::getName() method

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | None
| License       | MIT
| Doc PR        | symfony/symfony-docs#11705

The PR adds `Symfony\Component\DomCrawler\Form::getName` method.

The method is actually a syntax sugar but can improve DX when dealing with tests. For example, in the snippet

```php
$client = static::createClient();
$crawler = $client->request('GET', '/post/hello-world');
$form = $crawler->selectButton('submit')->form();

$form['my_form[name]'] = 'Fabien';
$form['my_form[subject]'] = 'Symfony rocks!';
```
the prefix in field name (`my_form`) is form name, which is generated by Symfony automatically. The method, added in the PR helps to get that name in a most obvious way.

Commits
-------

ff53cb4 [DomCrawler][Feature][DX] Add Form::getName() method
@JustBlackBird

This comment has been minimized.

Copy link
Contributor Author

commented Jun 14, 2019

You're welcome @fabpot 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.