Symfony Admin Generator Select Value

Discussion relating to version 1.3.x and 1.4.x

Symfony Admin Generator Select Value

Postby mdlugi » Tue Dec 06, 2011 12:42 pm

Hi @ all,

got a little problem with the generated forms from admin generator.
I got a select field called contenttype_id which is related to a table called contenttype_fields.
The table contenttype_fields has following fields

id
contenttype
name
subname

so... my problem is that the admin generator automatically chooses the name field as value for the select.
But i want it to choose the contenttype field as value.

is there any option in generator.yml to set value from name-field to another field? Or has anybody other suggestions?
greets
maZe
mdlugi
Junior Member
 
Posts: 16
Joined: Wed Jul 02, 2008 4:16 pm

Re: Symfony Admin Generator Select Value

Postby fabalexbar » Wed Dec 14, 2011 10:00 pm

Symfony automaticaly looks for name fields, if you want to use other field, you have a couple of options: you can define the method __toString() for the class using the fields you want, or you can define a query or table_method in the form class. In your case, defining the __toSting() method is the easiest way.

In case you don't know, you must add the method in the lib/model/doctrine folder (or lib/model/propel) in the MyClassName.class.php.
fabalexbar
Junior Member
 
Posts: 26
Joined: Wed May 28, 2008 6:29 pm
Location: Colombia


Return to symfony 1.3 and 1.4

Who is online

Users browsing this forum: No registered users and 6 guests