Thursday, 15 April 2010

Symfony overiding form fosuser omit getParent gives me error -


I'm just reading FOSuserbundle override forms. It says that:

If you do not want to reuse the fields included in the FOSUserBundle by default, you can leave the getParent method and all fields can be configured manually.

When I do this, it gives me an error.

Any help will greatly appreciate.

My simple code

  name space CTC \ bundle \ user bundle \ form type; Use Symfony \ Component \ Form \ AbstractType; Use Symfony \ Component \ Form \ FormBuilderInterface; Class RegistrationFormat Type AbstractType {Public Function BuildForm (Forfbuilder Interface $ builder, array $ option) Expands {// Form Field $ Builder-> Add ('User Eligibility', Faucet, Array ('Label' = & gt; 'Title')); $ Builder- & gt; Add ('userFirstName'); } // If you do not want to reuse the fields added by FOSUserBundle by default, you can leave the getParent method and all fields can configure themselves // Public function getParent () // {// return 'fos_user_registration'; //} public function getName () {return 'ctc_user_registration'; }}  

Returns:

Type the visual data of the form Scalar, array or ArrayAccess is expected to be an example, But class CTC \ bundle \ user bundle \ unit \ is an example of the user. You can avoid this error by setting the "data_class" option to "CTC \ bundle \ userbundle \ unit \ user" or by adding a visual transformer to the square CTC \ bundle \ user bundle \ unit \ user's scaler, array or \ ArrayAccess An example of

You can use the setDefault function:

  1. Add Usage Statement.

    Use Symphony \ optionsResolver \ optionsResolverInterface;

  2. Add function

      Public function set default options (OptionsResolverInterface $ resolver) {$ resolver- & gt; Set Defaults (array ('data_class' = & gt;' YamilovS \ MyESchoolBundle \ Entity \ User ',' Intention '=>; Registration',)); }  

No comments:

Post a Comment