Skip to content

[Form] Display general forms information on debug:form #24185

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
Sep 15, 2017

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Sep 13, 2017

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

debug-form-defaults

When we run bin/console debug:form (without argument) all possible Form Component information is displayed.

protected function describeDefaults(array $options = array())
{
$data['builtin_form_types'] = $this->getCoreTypes();
$data['services_form_types'] = array_values(array_diff($options['types'], $data['builtin_form_types']));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builtin types will be all from $options['types'] within Symfony\Component\Form\Extension\Core\Type\ namespace no? Isnt that more easy to do instead of getCoreTypes hack.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also i prefer services types to be shown above built in ones. Personal pref though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builtin types will be all from $options['types'] within Symfony\Component\Form\Extension\Core\Type\ namespace no?

Nope, only those registered, the most of them aren't services.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Perhaps add static getter for that in FormRegistry, as little new feat. But reflection is fine as well i guess xD

Copy link
Member Author

@yceruto yceruto Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add static getter for that in FormRegistry, as little new feat.

Not sure how to do that, because "types" is concern of FormExtensionInterface instances and loadTypes() method or types property after initTypes() in AbstractExtension (both inaccessible directly) so would need hack it anyway.

Copy link
Contributor

@ro0NL ro0NL Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was FormRegistry::getCoreTypes with the implem. of CoreExtension::loadTypes which in turn does simply return FormRegistry::getCoreTypes();.

For this PR you'd use FormRegistry::getCoreTypes() as well. CoreExtension::getTypes might do also :)

Copy link
Member Author

@yceruto yceruto Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, still not sure if worth it just for debug purpose. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True 👍

@yceruto yceruto force-pushed the debug_form_defaults branch from c692654 to 5678081 Compare September 13, 2017 17:06
Copy link
Contributor

@ogizanagi ogizanagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still a bit worried about the fact the command does only list types registered as a service, which can be a bit confusing for users not finding their own types or some third party ones. But the fact you explicit the "core types" and "services types" sections looks enough to me.

Built-in form types
-------------------

* Symfony\Component\Form\Extension\Core\Type\FormType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering: What about removing the namespace for core types when using the txt descriptor? (perhaps mentioning it only once above, in a comment or the section).

Copy link
Contributor

@ro0NL ro0NL Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A long list of short words is also not ideal btw. But 👍 for using short names anyway. Perhaps play a bit with comma separated variants.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Improved core types representation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

@yceruto yceruto force-pushed the debug_form_defaults branch from 5678081 to 01eda09 Compare September 13, 2017 18:14
@yceruto
Copy link
Member Author

yceruto commented Sep 13, 2017

Screenshot updated!

@ro0NL
Copy link
Contributor

ro0NL commented Sep 13, 2017

alpha order?

@yceruto yceruto force-pushed the debug_form_defaults branch from 01eda09 to e418d14 Compare September 13, 2017 18:46
@yceruto
Copy link
Member Author

yceruto commented Sep 13, 2017

I'm still a bit worried about the fact the command does only list types registered as a service, which can be a bit confusing for users not finding their own types or some third party ones...

@ogizanagi we know the path of installed bundles, we have best practices that say us the directory where would put the form types, what do you think about a discovery option to search subclasses of AbstractType using the Finder component? This operation we would only do it using --vvv option. (in another PR)

@yceruto yceruto force-pushed the debug_form_defaults branch from e418d14 to efe4180 Compare September 13, 2017 22:35
@yceruto
Copy link
Member Author

yceruto commented Sep 13, 2017

Just updating the help description.

@ogizanagi
Copy link
Contributor

we know the path of installed bundles, we have best practices that say us the directory where would put the form types, what do you think about a discovery option to search subclasses of AbstractType using the Finder component?

Form types could be in so many places, including not in a bundle at all. Searching them by convention, which is more a beginner best practice than a canon, probably isn't a satisfying enough solution.

@yceruto
Copy link
Member Author

yceruto commented Sep 14, 2017

Form types could be in so many places, including not in a bundle at all. Searching them by convention, which is more a beginner best practice than a canon, probably isn't a satisfying enough solution.

True, it was just a vague idea, I meant, Forms path best practices can be used first, later anywhere, but probably it would be too much.

@ro0NL
Copy link
Contributor

ro0NL commented Sep 14, 2017

Convenience wise i like the discovery of types with --discover or -v as proposed. Making this command so much more useful; we need to do something IMHO.

At least passing an arbitrary FQCN, which is a form type, should be allowed. Discovery wise i wouldnt be against a lookup in src/Form; src/**/Form; vendor/*/*/Form; vendor/*/*/**Form/.

@yceruto
Copy link
Member Author

yceruto commented Sep 14, 2017

I have another PR ready for debug a form type "option" but I'd like avoid conflicts later with this one. Please @symfony/deciders or reviewers? @chalasr since you're familiarized with the command, can I ask for your opinion?

{
$coreTypes = $this->getCoreTypes();

$this->output->section('Built-in form types (Symfony\Component\Form\Extension\Core\Type)');
Copy link
Contributor

@ro0NL ro0NL Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not bound to OutputInterface but StyleInterface. Are we being pragmatic here? Should we?

$output = $this->output instanceof StyleInterface ? $this->ouput : new SymfonyStyle($this->output);

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we are subject to DescriptorInterface signature.

Copy link
Member Author

@yceruto yceruto Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks!

"Symfony\\Component\\Form\\Extension\\Core\\Type\\TimezoneType",
"Symfony\\Component\\Form\\Extension\\Core\\Type\\UrlType"
],
"services_form_types": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id sayservice_form_types (no double pluralization)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@yceruto yceruto force-pushed the debug_form_defaults branch from f846fc6 to 78d1780 Compare September 14, 2017 14:41
@yceruto yceruto changed the title [Form] Display form defaults in debug:form [Form] Display forms information on debug:form Sep 14, 2017
@yceruto yceruto changed the title [Form] Display forms information on debug:form [Form] Display general forms information on debug:form Sep 14, 2017
@ogizanagi
Copy link
Contributor

Thanks Yonel.

@ogizanagi ogizanagi merged commit 12d1a7f into symfony:3.4 Sep 15, 2017
ogizanagi added a commit that referenced this pull request Sep 15, 2017
… (yceruto)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Display general forms information on debug:form

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

![debug-form-defaults](https://user-images.githubusercontent.com/2028198/30436620-998103ca-993a-11e7-9873-31f042327374.png)

When we run `bin/console debug:form` (without argument) all possible Form Component information is displayed.

Commits
-------

12d1a7f Display form defaults on debug:form
@yceruto yceruto deleted the debug_form_defaults branch September 15, 2017 16:43
symfony-splitter pushed a commit to symfony/form that referenced this pull request Oct 9, 2017
…e (yceruto, ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Display option definition from a given form type

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes (deps=high failure expected)
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

![debug-form-option](https://user-images.githubusercontent.com/2028198/30569305-12a30738-9ca8-11e7-98b7-6eaf78d3d5a7.png)

Show friendly message if typo:
![debug-form-not-found](https://user-images.githubusercontent.com/2028198/30450999-83d58b56-9960-11e7-8705-b60ba33baf48.png)

complement of symfony/symfony#24185

Commits
-------

d6d187d26e Add & use OptionResolverIntrospector
8bbb5e7884 Add debug:form type option
fabpot added a commit that referenced this pull request Oct 9, 2017
…e (yceruto, ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Display option definition from a given form type

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes (deps=high failure expected)
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

![debug-form-option](https://user-images.githubusercontent.com/2028198/30569305-12a30738-9ca8-11e7-98b7-6eaf78d3d5a7.png)

Show friendly message if typo:
![debug-form-not-found](https://user-images.githubusercontent.com/2028198/30450999-83d58b56-9960-11e7-8705-b60ba33baf48.png)

complement of #24185

Commits
-------

d6d187d Add & use OptionResolverIntrospector
8bbb5e7 Add debug:form type option
This was referenced Oct 18, 2017
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.

6 participants