opened
webmozart
username_0
As originally discussed in #11185, a default implementation should be added for `AbstractType::getName()`:

* `getName()` should return the type's FQCN by default
* the alias should be se4t to the class name by default in the DI config
* the form name should be set to the lower-cased short name of the type by default, minus the "type" suffix

Before:

```php
class TaskType extends AbstractType
{
    public function getName()
    {
        return 'task';
    }
}
```

```yaml
services:
    acme.demo.form.task:
        class: Acme\DemoBundle\Form\TaskType
        tags:
            - { name: form.type, alias: task }
```

```php
$form = $this->createForm(new TaskType());
// or
$form = $this->createForm('task');

echo $form->getName();
// task
```

After:

```php
class TaskType extends AbstractType
{
}
```

```yaml
services:
    acme.demo.form.task:
        class: Acme\DemoBundle\Form\TaskType
        tags:
            - { name: form.type }
```

```php
$form = $this->createForm(new TaskType());
// or
$form = $this->createForm(TaskType::class);
// or
$form = $this->createForm('Acme\DemoBundle\Form\TaskType');

echo $form->getName();
// task
```
[Form] Add default implementation for AbstractType::getName()
issue
created
iltar
username_1
I think this is a nice idea for services, but what about multiple services that automatically get the same alias? `\Foo\BarType` and `\Baz\BarType` would create an automatic conflict and could create problems between 3rd party bundles.
comment
created
stof
username_2
form names don't need to be unique (unless you try to submit them in the same request, which would be really weird). And type names will not conflict by default as the default value would be the FQCN
comment
created
iltar
username_1
@username_2 so the Alias would default to `TaskType::class`? That would make sense. I Misunderstood it and thought the idea was to put `task` as alias, but `task` will only be the name.
comment
created
webmozart
username_0
Implemented in #15079.
comment
closed
fabpot
username_3
issue