Ask your Symfony questions! Pay money and get answers fast! (more info)

What schema do I use for generated embedded forms? Symfony

Symfony 1.4 using Propel.

So, we have a site that offers deals, which can happen on a date, or they can recur on certain days of a week. For instance, a restaurant might decide that every Tuesday they will offer 50% off the lobster dinner.

So we have a database table called "weekday" which does nothing more than hold the 7 days of the week:

mysql> explain weekday;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+


This database just has 7 entries in it, for each of the 7 days.

The table deal_weekday matches the weekdays to the deal:

mysql> explain deal_weekday;
+------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+-------+
| weekday_id | int(11) | NO | PRI | NULL | |
| deal_id | int(11) | NO | PRI | NULL | |
| created_at | datetime | YES | | NULL | |
+------------+----------+------+-----+---------+-------+


In the schema.yml file, we model the 3 tables like this:

deal:
id:
app_id: { type: integer, required: true, foreignTable: app, foreignReference: id, onDelete: cascade }
title: varchar(255)
deal: varchar(255)
starts_at: timestamp
ends_at: timestamp
place_id: { type: integer, required: true, foreignTable: place, foreignReference: id, onDelete: cascade }
limited_to: integer
is_recurring: boolean
push_before_sec: integer
push_text: longvarchar
image: varchar(255)


weekday:
id:
name: varchar(255)


deal_weekday:
weekday_id: { type: integer, primaryKey: true, required: true, foreignTable: weekday, foreignReference: id, onDelete: cascade }
deal_id: { type: integer, primaryKey: true, required: true, foreignTable: deal, foreignReference: id, onDelete: cascade }
created_at:


We are trying to use generators to auto-generate most of the forms. I can easily create the form for the deals, but if I want to also, within that form, have a list of the 7 days of the week, preferably as checkboxes, what do I do? I know I can go into the cache folder and find the HTML fragment that has been auto-generated and I can copy that to the module inside the apps directory and I can there customize it, but I am curious, is there way to avoid that? Is there a way to get the generator to do this for me?






Answers (0)

No answers yet.