Hi there,

I'm building a web application with symfony+doctrine for my local
universities faculty.
The problem I am having is that I have declared several m2m relations
within my database model, and now I have to build a form to query my
users for a table and its associated tables.

Schema snippet:
---
TeachingOffer:
  columns:
    id: { type: integer(4), primary: true, autoincrement: true }
    name: { type: string(255), notnull: true }
  relations:
    StudyCategories: { class: StudyCategory, refClass:
TeachingOfferStudyCategory, foreign: study_category_id, local:
teaching_offer_id, foreignAlias: TeachingOffers }

StudyCategory:
  columns:
    id: { type: integer(4), primary: true, autoincrement: true }
    name: string(255)
    abbr: string(255)
    url: { type: clob, notnull: true }
  relations:
    TeachingOffers: { class: TeachingOffer, refClass:
TeachingOfferStudyCategory, local: study_category_id, foreignAlias:
StudyCategories, foreign: teaching_offer_id }

TeachingOfferStudyCategory:
  columns:
    id: { type: integer(4), primary: true, autoincrement: true }
    teaching_offer_id: integer(4)
    study_category_id: integer(4)
    exam_type_id: { type: integer(4) }
    module: { type: string(255) }
    compulsory_type: { type: enum, values:
['compulsory','elective','compulsory elective'] }
  relations:
    TeachingOffer: { local: teaching_offer_id, foreign: id, onDelete:
CASCADE, onUpdate: CASCADE }
    StudyCategory: { local: study_category_id, foreign: id, onDelete:
SET NULL, onUpdate: CASCADE }
    ExamType: { local: exam_type_id, foreign: id, class: ExamType,
onUpdate: CASCADE, onDelete: SET NULL }
---

My users are supposed to fill in a form for my TeachingOffers and from
there associate it with one-many StudyCategories. What complicates
this is, that they have to provide further data, which makes up this
relation. So sfWidgetFormDoctrineChoiceMany is no option for me,
because it can only associate 2 tables, not query for extra
information.

I tried to embed subforms for every StudyCategory, but these do not
update/save correctly.
Form code snippet:
---
foreach($this->getObject()->getTeachingOfferStudyCategory() as $idx=>
$sc){
  $fieldname = 'study_cat'.$idx;

  $scform = new TeachingOfferStudyCategoryForm($sc);

  $studycats->embedForm($fieldname, $scform);

  $studycats->widgetSchema->setLabel($fieldname,($idx+1).".
Kategorie<br/>".$lbl);
}
---

Although I can see the subforms TeachingOffer foreign key to be set,
when inspecting the HTML with firebug, it doesn't get saved to the
database. And on updating/editing, the values are not read from the DB
and processed into the form.

So, what am I missing?
Or is there a way of embedding several subforms with extra fields,
while maintaining data coherence?
And is there a way to address these subforms from the Template file
(so they can get a single label)?

Greetz,

BigBadBassMan (BBBM)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to