J'ai trouvé la cause de l'erreur. J'avais omis de faire
$this->widgetSchema->setNameFormat('entreprise[%s]');
100 coups de baton dans les mains, je mérite bien.
Par contre je suis aux prises avec une autre difficulté. En réalité le schéma que j'ai fourni ci-dessus n'était pas complet. Ma table entreprise est en relation n:n avec la table opération. Schéma complet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| entreprise:
actAs:
Timestampable: ~
I18n:
fields: [activite, description, is_validated]
columns:
nom:
type: string(255)
activite:
type: string(255)
image:
type: string(255)
description:
type: clob
capital:
type: string(255)
is_validated:
type: boolean
default: false
relations:
operation:
class: operation
refClass: entrepriseoperation
foreignAlias: entreprise
entrepriseoperation:
columns:
entreprise_id:
type: integer
primary: true
operation_id:
type: integer
primary: true
relations:
entreprise:
foreignAlias: entrepriseoperation
onDelete: cascade
operation:
foreignAlias: entrepriseoperation
onDelete: cascade
operation:
actAs:
I18n:
fields: [nom]
actAs:
Sluggable:
fields: [nom]
uniqueBy: [lang, nom]
columns:
nom:
type: string(255) |
Dans mon entrepriseActions, j'ai fait ceci:
1 2 3 4 5 6 7 8 9 10 11 12
| public function executeNew(sfWebRequest $request)
{
$this->culture = $this->getUser()->getCulture();
$this->op = Doctrine_Core::getTable('operation')->findBySlug($request->getParameter('slug'));
$this->forward404Unless($this->op);
$newEnt = new entreprise();
$newEnt->setOperation($this->op);
$this->form = new entrepriseForm($newEnt, array('culture' => $this->getUser()->getCulture()));
} |
puis dans le configure de entrepriseForm, je passe le champ operation_list en hidden:
'operation_list' => new sfWidgetFormInputHidden(),
Ca marchait bien avant l'embed de la form i18n, mais depuis son intégration, ca ne marche plus. Mais quand je refais ceci:
'operation_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'operation')),
, ca marche bien. Or moi je veux absolument passer le operation_list en hidden. Une astuce, svp ? Merci
Partager