Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Symfony]sfWidgetFormPropelChoice i multiple
Forum PHP.pl > Forum > PHP > Frameworki
trucksweb
mam problem z taka tabela w symfony:

wiaze uzytkownika z innymi uzytkownikami i mam taka tabele:

catalog_user_account:
id_warder:
type: INTEGER
required: true
primaryKey: true
foreignTable: catalog_user_account
foreignReference: id_user_account
onDelete: CASCADE
onUpdate: CASCADE
id_user_account:
type: INTEGER
required: true
primaryKey: true
foreignTable: catalog_user_account
foreignReference: id_user_account
onDelete: CASCADE
onUpdate: CASCADE



forma wyglada tak:
  1. $c = new Criteria();
  2. $c->addMultipleJoin(array(array(CatalogUserAccountPeer::ID_USER_GROUP, CatalogUserGroupPeer::ID_USER_GROUP),
  3. array(CatalogUserGroupPeer::CODE_NAME, '"user"')));
  4.  
  5.  
  6. $this->setWidgets(array(
  7. 'id_warder' => new sfWidgetFormChoice(array('choices' => CatalogLedScreenUserAccount::getWardersArray())),
  8. 'id_user_account' => new sfWidgetFormPropelChoice(array('model' => 'CatalogUserAccount', 'criteria' => $c, 'multiple'=>true))
  9. ));
  10.  
  11. $this->setValidators(array(
  12. 'id_warder' => new sfValidatorPropelChoice(array('model' => 'CatalogUserAccount', 'column' => 'id_user_account', 'required' => false)),
  13. 'id_user_account' => new sfValidatorPropelChoice(array('model' => 'CatalogUserAccount', 'multiple' => true)),
  14. ));


i teraz przesylajac dane:
  1. $array['id_warder'] = 1
  2. $array['id_user_account'] = array(0 => 2, 1 => 3);


i zapisuje mi tylko id_warder, i 1 jako id_user_account

chce zeby utworzylo mi dwa wpisy w bazie przy jednym zapisie:
id_warder, id_user_account
1, 2
1, 3

dlaczego ?


//edit
odpowiem sobie sam ze to raczej nie jest wykonalne, byc moze cos sknocilem w bazie ale rozwiazalem to w inny sposob:

stworzylem sobie tabele tylko i wylacznie z id_warder jako kluczem glownym

potem spec_warder_user:
id_warder (relacja do tej tabeli wylacznie z id_warder)
id_user (relacja do users)

i teraz wszystko pieknie smiga smile.gif
jaro87
W 1.4 taka schema nawet nie pozwala na przebudowanie modelu:

Kod
1:1 relationship expressed by foreign key catalog_user_account_FK_2 is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.


Której konkretnie wersji Symfony używasz?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.