Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SF][Symfony]Symfony - relacja n:m - sfWidgetFormPropelChoice
mitas
post
Post #1





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 29.07.2009

Ostrzeżenie: (0%)
-----


Witam, przejdę od razu do rzeczy wink.gif :

Mam taki chemat w bazie danych:
  1. <table name="kongres" isI18N="true" i18nTable="kongres_i18n">
  2. <column name="id" type="integer" required="true" autoIncrement="true" primaryKey="true"/>
  3. <column name="is_actived" type="boolean" default="0"/>
  4. <column name="is_homepage" type="boolean" default="0"/>
  5. <column name="template" type="VARCHAR" size="50" required="true"/>
  6. <column name="produkt" type="integer" required="true"/>
  7. </table>
  8.  
  9. <table name="menugroup">
  10. <column name="id" type="integer" required="true" autoIncrement="true" primaryKey="true"/>
  11. <column name="tytul" type="varchar" size="255"/>
  12. </table>
  13.  
  14. <table name="kongresmenugroup">
  15. <column name="id" type="integer" required="true" autoIncrement="true" primaryKey="true"/>
  16. <column name="kongres_id" type="integer" required="true"/>
  17. <foreign-key foreignTable="kongres" onDelete="CASCADE">
  18. <reference local="kongres_id"
  19. foreign="id"/>
  20. </foreign-key>
  21. <column name="menugroup_id" type="integer" required="true"/>
  22. <foreign-key foreignTable="menugroup" onDelete="CASCADE">
  23. <reference local="menugroup_id"
  24. foreign="id"/>
  25. </foreign-key>
  26. </table>


Po wykonaniu poprawnie poleceń: symfony propel:build-model oraz symfony propel:build-forms dostalem taki formularz (dodałem opcję mulitple oraz expanded, ponieważ potrzrebuję zapisać więcej kongresów niż jeden pod menu) (backend):
  1. public function configure()
  2. {
  3.  
  4. $this->setWidgets(array(
  5. 'id' => new sfWidgetFormInputHidden(),
  6. 'kongres_id' => new sfWidgetFormPropelChoice(array('model' => 'Kongres', 'add_empty' => false, 'expanded' => true, 'multiple' => true)),
  7. 'menugroup_id' => new sfWidgetFormPropelChoice(array('model' => 'Menugroup', 'add_empty' => false)),
  8. ));
  9.  
  10. $this->setValidators(array(
  11. 'id' => new sfValidatorPropelChoice(array('model' => 'Kongresmenugroup', 'column' => 'id', 'required' => false)),
  12. 'kongres_id' => new sfValidatorPropelChoice(array('model' => 'Kongres', 'column' => 'id','multiple' => true)),
  13. 'menugroup_id' => new sfValidatorPropelChoice(array('model' => 'Menugroup', 'column' => 'id','multiple' => true)),
  14. ));
  15.  
  16. $this->widgetSchema->setNameFormat('kongresmenugroup[%s]');
  17.  
  18. $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
  19.  
  20.  
  21. }


I teraz moje pytanie, niby bo klkinięciu SAVE zapisują się dane do bazy, tylko są one nie poprawne, zawsze zapisuje się dla pola: menugroup_id: 1 oraz kongres_id: 1, mimo że np. wybrany kongres ma ID = 21 a ID menu jest równe np. 3. Proszę powiedzcie co robię nie tak ponieważ pogubiłem się już wink.gif Dzięki !
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 05:06