Skip to content

[Form] Added getBlockPrefix() to ResolvedFormTypeInterface #16749

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
Nov 29, 2015

Conversation

webmozart
Copy link
Contributor

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

This is the follow-up PR to #16724.

If you call $form->getConfig()->getType(), all the methods of FormType should be usable. In that sense, ResolvedFormType is the developer-facing version of FormType.

It is true that the same could be achieved with getInnerType(), but that method should be used in edge cases only as it clutters the code and makes it confusing to read:

$blockPrefix = $form->getConfig()->getType()->getInnerType()->getBlockPrefix();

@Tobion
Copy link
Contributor

Tobion commented Nov 29, 2015

Thank you @webmozart.

@Tobion Tobion merged commit 7e89345 into symfony:master Nov 29, 2015
Tobion added a commit that referenced this pull request Nov 29, 2015
…ce (webmozart)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[Form] Added getBlockPrefix() to ResolvedFormTypeInterface

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This is the follow-up PR to #16724.

If you call `$form->getConfig()->getType()`, all the methods of FormType should be usable. In that sense, ResolvedFormType is the developer-facing version of FormType.

It is true that the same could be achieved with `getInnerType()`, but that method should be used in edge cases only as it clutters the code and makes it confusing to read:

```php
$blockPrefix = $form->getConfig()->getType()->getInnerType()->getBlockPrefix();
```

Commits
-------

7e89345 [Form] Added getBlockPrefix() to ResolvedFormTypeInterface
@xabbuh
Copy link
Member

xabbuh commented Nov 30, 2015

If you call $form->getConfig()->getType(), all the methods of FormType should be usable. In that sense, ResolvedFormType is the developer-facing version of FormType.

Would it make sense then to let ResolvedFormTypeInterface extend the FormTypeInterface or also add the configureOptions() method to the interface?

@webmozart
Copy link
Contributor Author

@xabbuh Not really. ResolvedFormTypeInterface is just like FormType, but not exactly the same, as it also contains references to the parent type and its type extensions. So getParent() returns a ResolvedFormTypeInterface, while in FormType it returns a string. buildForm() builds the form, but also calls the parent and the extensions. And configureOptions() shouldn't be added since that's what getOptionsResolver() is for, which makes sure to always return the same instance (for performance reasons).

@xabbuh
Copy link
Member

xabbuh commented Nov 30, 2015

@webmozart I see, thanks for the explanation.

stof added a commit that referenced this pull request Dec 5, 2015
This PR was submitted for the master branch but it was merged into the 3.0 branch instead (closes #16752).

Discussion
----------

[Form] document changes to form type interfaces

| Q             | A
| ------------- | ---
| Fixed tickets | #13407, #16024, #16724, #16749
| License       | MIT

Commits
-------

b297a0c [Form] document changes to form type interfaces
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.

4 participants