sfGuardUser model of sfDoctrineGuardPlugin is defined this way:
sfGuardUser:
actAs: [Timestampable]
columns:
id:
type: integer(4)
primary: true
autoincrement: true
username:
type: string(128)
notnull: true
unique: true
As you can see 'username' has the feature "notnull:true". Now i want to create a register form that is not using 'username' but the email address of the user.
When a user wants to register, it is showed this:
Validation failed in class sfGuardUser 1 field had validation error: * 1 validator failed on username (notnull)
Any idea?
Javi
In symfony 1.4 final classes are generated to main lib directory so you could modify them in project.
Therefore in lib/model/doctrine/sfDoctrineGuardPlugin/sfGuardUser.class.php file you are able to overwrite setUp() method which is responsible for model definition:
Some of the plugin schema fields are easily adjustable without code tweaks, while others will throw an error.
You could try removing "notnull: true" from the username field in the schema, but it may throw an error (haven't tried). In this case, you can either tweak the plugin code (=headache), or ensure that a value is always saved to that field, such as a zero. This way it's never null.
I finally overwrite the schema with another schema that says "notnull:false". This is possible from sf1.3.
you could fix
lib/form/doctrine/sfGuardPlugin/sfGuardUserForm.class.php
in following way: