// ЦСИ \ форма;
namespace src\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name',TextType::class,array(
'label' => 'Nom',
'required' => TRUE,
'attr' =>array(
'class='=>'form-group form-control'
)
))
->add('firstname',TextType::class,array(
'label' => 'Prénom',
'required' => TRUE,
'attr' =>array(
'class='=>'form-group form-control'
)
))
;
}
public function getParent(){
return BaseRegistrationFormType::class;
}
public function getBlockPrefix()
{
return 'app_user_registration';
}
}
// config \ services.yaml
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: 'fr'
services:
app.form.registration:
class: AppBundle\Form\RegistrationFormType
tags:
- { name: form.type }
- { firstname: form.type }
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,EventListener,Migrations,Tests,Kernel.php}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
// config \ fos_user.yaml
fos_user:
db_driver: orm
user_class: App\Entity\User
firewall_name: main
service:
mailer: fos_user.mailer.noop
from_email:
address: "sebvrg@gmail.com"
sender_name: "sebvrg@gmail.com"
registration:
form:
type: AppBundle\Form\RegistrationFormType
// вывод в консоль:
In FileLoader.php line 166:
A "tags" entry is missing a "name" key for service "app.form.registration" in C:\Users\sebvr\Desktop\Projets\SELT\selt\config/services.yaml in C:\Users\sebvr\Deskt
op\Projets\SELT\selt\config/services.yaml (which is loaded in resource "C:\Users\sebvr\Desktop\Projets\SELT\selt\config/services.yaml").
In YamlFileLoader.php line 489:
A "tags" entry is missing a "name" key for service "app.form.registration" in C:\Users\sebvr\Desktop\Projets\SELT\selt\config/services.yaml.