Reputation: 197
I would like add form services with security context as bellow:
namespace Infogold\AccountBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\SecurityContext;
use Doctrine\ORM\EntityRepository;
class KonsultantType extends AbstractType {
protected $user;
public function __construct(SecurityContext $user) {
$this->user = $user;
}
public function buildForm(FormBuilderInterface $builder, array $options) {
-
-
-
-
-
-
public function getName() {
return 'konsultanci_form';
}
In services :
parameters:
# infogold_account.example.class: Infogold\AccountBundle\Example
services:
form.type.konsultanci_form:
class: Infogold\AccountBundle\Form\KonsulantType
arguments: ['@security.context']
tags:
- { name: form.type, alias: konsultanci_form }
And I get this error:
FatalErrorException: Error: Class 'Infogold\AccountBundle\Form\KonsulantType' not found in D:\xampp\htdocs\symfony4\app\cache\dev\appDevDebugProjectContainer.php line 718
718 line is:
protected function getForm_Type_KonsultanciFormService()
{
return $this->services['form.type.konsultanci_form'] = new \Infogold\AccountBundle\Form\KonsulantType($this->get('security.context'));
}
Where I made a mistake ?
Upvotes: 1
Views: 4723
Reputation: 224
As I've said, it is a mistake on class name. It is KonsultantType
instead of KonsulantType
Try:
parameters:
# infogold_account.example.class: Infogold\AccountBundle\Example
services:
form.type.konsultanci_form:
class: Infogold\AccountBundle\Form\KonsultantType
arguments: ['@security.context']
tags:
- { name: form.type, alias: konsultanci_form }
Upvotes: 1