1

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 ?

3
  • You created a class which name is KonsultantType. And in your service.yml, you put the class as Infogold\AccountBundle\Form\KonsulantType. It is a little mistake on class name. Commented Jan 24, 2015 at 12:53
  • It's normal to specify namespace in service configration, do you have refreshed the cache ? with cache:clear command ? oh sorry @marcoshoya i did'nt saw the mistake on classname Commented Jan 24, 2015 at 13:29
  • @JonaPkr In the class the name is KonsulTANTtype. On service file, the name is KonsuLANTtype. See again ;) Commented Jan 24, 2015 at 17:02

1 Answer 1

1

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 }  
Sign up to request clarification or add additional context in comments.

1 Comment

yeah didn't saw the mistype, i thought you were talking about the fact that the namespace was specified. upvote for u :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.