Skip to content

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

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

Merged
merged 1 commit into from
Jun 14, 2019

Conversation

JustBlackBird
Copy link
Contributor

@JustBlackBird JustBlackBird 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
Copy link
Contributor

I like the idea !

@nicolas-grekas nicolas-grekas added this to the next milestone Jun 9, 2019
@fabpot fabpot force-pushed the dom-crawler-form-name branch from 8095c37 to ff53cb4 Compare June 14, 2019 05:15
@fabpot
Copy link
Member

fabpot commented Jun 14, 2019

Thank you @JustBlackBird.

@fabpot fabpot merged commit ff53cb4 into symfony:4.4 Jun 14, 2019
fabpot added a commit that referenced this pull request Jun 14, 2019
…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
Copy link
Contributor Author

You're welcome @fabpot 😄

@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants