Reputation: 71
I tried to create a service in Symfony 2.2 for one of my form :
service.yml:
tyg_user.settings.form:
class: Symfony\Component\Form\Form
factory_method: createNamed
factory_service: form.factory
arguments:
- tyg_user_settings
- tyg_user_settings_name
tyg_user.settings.form.type:
class: TyG\UserBundle\Form\Settings\SettingsFormType
tags:
- { name: form.type, alias: tyg_user_settings }
tyg_user.settings.form.handler:
class: TyG\UserBundle\Form\Settings\SettingsFormHandler
scope: request
arguments:
- @tyg_user.settings.form
- @request
- @fos_user.user_manager
SettingsForm.php
<?php
namespace TyG\UserBundle\Form\Settings;
use Symfony\Component\Form\FormBuilderInterface as FormBuilder;;
use Symfony\Component\Form\AbstractType;
class SettingsForm extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('birthday', 'birthday')
->add('email', 'email')
->add('showmail')
->add('showbirthday')
;
}
public function getName()
{
return 'tyg_user_settings';
}
}
?>
But an error occuered :
Could not load type "tyg_user_settings_name
This occurs when I get my form through the service container :
$this->container->get('tyg_user.settings.form');
I used to do create my service through the xml format but when I change to the yml format I can't figure out how to to make it works
Upvotes: 0
Views: 1175
Reputation: 17759
The tyg_user_settings_name
is referencing a form type alias.
If you are wanting it to reference a parameter you should use %tyg_user_settings_name%
instead.
Upvotes: 2