views:

34

answers:

2

Hi, I'm trying to remove some fields from the form generated by sfDoctrineGuard. I don't care about the name or email of my users, I just want them to have an username and a password.

alt text

I've tried editing /lib/form/doctrine/sfDoctrineGuardPlugin/sfGuardUserForm.class.php :

class sfGuardUserForm extends PluginsfGuardUserForm
{
  public function configure()
  {
    unset(
      $this['first_name'],
      $this['last_name'],
      $this['email_adress']
    );


  }
}

But that did nothing. Am I editing the right file ?

EDIT The only way I can make those fields disappear is by editing the file in the /plugins/ directory !

plugins/sfDoctrineGuardPlugin/lib/form/doctrine/sfGuardUserAdminForm.class.php

A: 

These fields are configured in generator.yml file. But removing there will not work as you expected. You need to manually remove these fields from schema.yml, form- and model classes.

Darmen
I just want to hide them in the form, they can still be in the database, I don't care.
Manu
I don't have a generator.yml to edit, it is in the plugin folder
Manu
-1, as you shouldn't edit the plugin's schema
benlumley
@benlumbey ok, does symfony provide a way to customize plugin schemas?
Darmen
i don't think it does no - only editing the core files, which is bad as it means you can't upgrade so easily. Bit of a nuisance at times. You can half get there by copying/duplicating bits of schema.yml, but its not great.
benlumley
+2  A: 

Its probably using sfGuardUserAdminForm rather than sfGuardUserForm - check the view tab of the debug bar and it should tell you.

This class lives in the plugin, so you should subclass it under your project's lib/form folder and copy your existing configure method to the subclass.

You can then tell it to use this form by editing gnerator.yml - again, copy it to your project/application's modules folder from the plugin if you haven't already. You need to change generator/param/config/form/class. You also need to remove the fields from the form/display key if they are there, or it'll complain they don't exist.

benlumley