default form in Symfony - add new input and change choice
my schema.yml :
User:
columns:
id:
type: integer(4)
autoincrement: true
primary: true
username:
type: string(255)
password:
type: string(255)
attributes:
export: all
validate: true
Group:
tableName: group_table
columns:
id:
type: integer(4)
autoincrement: true
primary: true
name:
type: string(255)
relations:
Users:
foreignAlias: Groups
class: User
refClass: GroupUser
GroupUser:
columns:
group_id:
type: integer(4)
primary: true
user_id:
type: integer(4)
primary: true
relations:
Group:
foreignAlias: GroupUsers
User:
foreignAlias: GroupUsers
additional:
columns:
id:
type: inte开发者_高级运维ger(4)
autoincrement: true
primary: true
new:
type: string(255)
attributes:
export: all
validate: true
i generated new module:
php symfony doctrine:generate-module --with-show --non-verbose-templates frontend user User
and i have form add user:
http://localhost/user/new
image: http://img692.imageshack.us/img692/7726/znew.png
i would like add for this form input new from the module additional and change the sfWidgetFormDoctrineChoice for multiple checkbox. how can i make it?
THX!
sfWidgetFormDoctrineChoice has an option called 'expanded' that if it's on true then will display the options with checkboxes (check this example from the symfony's Jobeet).
In your UserForm.class.php you have to put something like this (check your BaseUserForm.class.php)
<!-- lib/form/doctrine/UserForm.class.php -->
...
public function configure(){
$this->setWidget('groups_list', new sfWidgetFormDoctrineChoice(array(
'multiple' => true,
'model' => 'Group', //check that on your base
'expanded' => true, //set checkboxs
)));
}
...
精彩评论