Closed
Description
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:
class TaskType extends AbstractType
{
public function getName()
{
return 'task';
}
}
services:
acme.demo.form.task:
class: Acme\DemoBundle\Form\TaskType
tags:
- { name: form.type, alias: task }
$form = $this->createForm(new TaskType());
// or
$form = $this->createForm('task');
echo $form->getName();
// task
After:
class TaskType extends AbstractType
{
}
services:
acme.demo.form.task:
class: Acme\DemoBundle\Form\TaskType
tags:
- { name: form.type }
$form = $this->createForm(new TaskType());
// or
$form = $this->createForm(TaskType::class);
// or
$form = $this->createForm('Acme\DemoBundle\Form\TaskType');
echo $form->getName();
// task