Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$4
How to get a checkbox in a generated admin module?
[UPDATE]
I'm using Symfony 1.4.
I do this to create the admin module:
./symfony doctrine:generate-admin tastingnotes Importer --module=importer
In schema.yml, for Importer, I have this:
Importer:
actAs: [Timestampable]
tableName: importer
columns:
id:
type: integer
primary: true
autoincrement: true
found_count_from_tastings_sql: string(255)
address_sql: string(255)
address2_sql: string(255)
address2and_sql: string(255)
address2more_sql: string(255)
addressand_sql: string(255)
addressmore_sql: string(255)
alsace_sql: boolean
argentina_sql: boolean
australia_sql: boolean
austria_sql: boolean
bordeaux_sql: boolean
burgundy_sql: boolean
champagne_sql: boolean
chile_sql: boolean
city_sql: string(255)
city2_sql: string(255)
contact_sql: string(255)
contact2_sql: string(255)
country_sql: string(255)
country2_sql: string(255)
dear_sql: string(255)
email_sql: string(255)
email2_sql: string(255)
extension_sql: string(255)
extension2_sql: string(255)
fax_sql: string(255)
fax2_sql: string(255)
germany_sql: boolean
goto_global_sql: string(255)
importer_sql: string(255)
importer_alpha_sql: string(255)
languedoc_sql: boolean
loire_sql: boolean
new_zealand_sql: boolean
notes_sql: string(255)
other_france_sql: boolean
other_italy_sql: boolean
phone_sql: string(255)
phone2_sql: string(255)
piedmont_sql: boolean
portugal_sql: boolean
rhone_sql: boolean
south_africa_sql: boolean
spain_sql: boolean
state_sql: string(255)
state2_sql: string(255)
title_sql: string(255)
title2_sql: string(255)
total_r_sql: string(255)
tuscany_sql: boolean
venetone_sql: boolean
website_sql: string(255)
winery_sql: string(255)
wineryimporter_sql: string(255)
zip_sql: string(255)
zip2_sql: string(255)
all1_sql: string(255)
all2_sql: string(255)
areacode_sql: string(255)
areacode2_sql: string(255)
france_sql: boolean
impcode_sql: string(255)
implog_sql: string(255)
impover_sql: string(255)
italy_sql: boolean
layoutname_calc_sql: string(255)
message_calc_sql: string(255)
message_global_sql: string(255)
partimp_sql: string(255)
partimp2_sql: string(255)
recno_sql: string(255)
record_id_sql: string(255)
relation_constant_sql: string(255)
subject_global_sql: string(255)
wineryimporter_check_sql: string(255)
wineryimporter_name_sql: string(255)
export_record_id_sql: string(255)
Look at the screenshot. You can see that some of the fields marked "boolean" are showing up as text fields, instead of checkboxes.
This question has been answered.
Lawrence Krubner | 11/02/10 at 5:23pm
Edit
Previous versions of this question:
11/03/10 at 12:56pm
(5) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
11/03/10
3:56pmArturo Linares says:If the field is boolean it should be rendered automatically as a checkbox. If not, you can always change the widget you are using in the WineForm class, in the configure() method.
-

Last edited:
11/02/10
5:35pmDamian Martinelli says:If you set the field as boolean, the checkbox will be shown automatically. If not, you can set the field to sfWidgetFormInputCheckbox on your form class.
-

Last edited:
11/02/10
5:45pmMarcos IbaƱez says:Please publish the part of your schema.yml that corresponds to the field you want to get the checkbox, so we can look deeper into it, since as Arturo and Damian correctly pointed out, if the field is boolean, the checkbox should be automatically generated.
-

Last edited:
11/03/10
3:56pmJoshua Estes says:Let's say you are working with the WineForm class. The widget is called "hasTasted". Look for the form in lib/form/doctrine/WineForm.class.php
class WineForm extends BaseWineForm
{
public function configure()
{
$this->widgetSchema['hasTasted'] = new sfWidgetFormInputCheckbox();
}
}
Since you already have the widget defined, you just want to change the type of widget. There are a few other ways to create checkboxes but since you just want something that is true/false this should be the easiest.
-

Last edited:
11/03/10
3:56pmFlorian Klein says:As said above, you need to set the type BOOLEAN on the fields of your schema.
Doctrine or Propel will save them as an integer on mysql, but they will generate checkbox widgets for the forms and filters classes.
To do so, you will need to:
* modify your schema to set boolean on the fields
* run the command:
php symfony doctrine:build --all-classes --sql
or
php symfony propel:build --all-classes --sql
Then, as the admin generator uses form classes to display the form, you will just need to
and refresh your screen.php symfony ccPrevious versions of this answer: 11/03/10 at 12:50pm
- 11/03/10 1:20pm
Florian Klein says:Another good way to help us debug your problem is to post the code of your ImporterFormFilter.class.php and BaseImporterFormFilter.class.php and ImporterForm.class.php and BaseImporterForm.class.php
Your filter widget schema should look like this:
$this->setWidgets(array(
// ...
'alsace_sql' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
// ...
));
You form widget schema should be like this
$this->setWidgets(array(
// ...
'alsace_sql' => new sfWidgetFormInputCheckbox(),
// ...
));
- 11/03/10 3:17pm
Lawrence Krubner says:I have this in my schema.yml:
alsace_sql: boolean
argentina_sql: boolean
australia_sql: boolean
austria_sql: boolean
Look at the screenshot. I'm getting text inputs instead of checkboxes.
- 11/03/10 1:20pm
This question has expired.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
