我有以下型号:
与会者 选项 铭文(订阅)
协会如下:
铭文有很多参与者
$this->hasMany('Participants', [
'foreignKey' => 'inscription_id'
]);
参与者所属于多种选择
$this->belongsToMany('Options', [
'joinTable' => 'options_participants',
]);
选项belongsToMany参与者
$this->belongsToMany('Participants', [
'joinTable' => 'options_participants',
]);
我想保存一个铭文
$_datas = $this->request->data;
$inscription = $this->Inscriptions->patchEntity($inscription, $_datas, ['associated' => ['Participants.Options']]);
$inscription->save();
这是我的每个参与者的形式(进入一个foreach循环)。
<?php
echo $this->Form->input('participants.' . $i . '.id');
echo $this->Form->input('participants.' . $i . '.civilite', ['type' => 'select', 'data-update' => 'civiliteUpdate', 'label' => 'Civilité*', 'empty' => '(choisissez)', 'options' => $_civilite, 'value' => $_participant->civilite]);
echo $this->Form->input('participants.' . $i . '.nom', ['class' => 'edit-nom', 'data-update' => 'nomUpdate', 'field' => 'nom', 'label' => 'Nom*', 'value' => $_participant->nom]);
echo $this->Form->input('participants.' . $i . '.prenom', ['class' => 'edit-prenom', 'data-update' => 'prenomUpdate', 'field' => 'prenom', 'label' => 'Prénom*', 'value' => $_participant->prenom]);
echo $this->Form->input('participants.' . $i . '.formule_id', ['type' => 'select', 'data-update' => 'formuleNomUpdate', 'field' => 'formule', 'data-url' => $this->Url->build(['controller' => 'Inscriptions', 'action' => 'ajaxReturnFormulePrice']), 'label' => 'Formule*', 'empty' => '(Choisissez)', 'options' => $formules, 'value' => $_participant->formule_id]);
echo $this->Form->label('participants.' . $i . '.dateDeNaissance', 'Date de naissance');
echo $this->Form->day('participants.' . $i . '.dateDeNaissance', ['label' => '', 'value' => $_participant->dateDeNaissance->day]);
echo $this->Form->month('participants.' . $i . '.dateDeNaissance', ['label' => '', 'value' => $_participant->dateDeNaissance->month]);
echo $this->Form->year('participants.' . $i . '.dateDeNaissance', ['label' => '', 'value' => $_participant->dateDeNaissance->year, 'minYear' => 1931, 'maxYear' => date('Y')]);
echo $this->Form->input('participants.' . $i . '.email', ['value' => $_participant->email, 'data-update' => 'emailUpdate']);
echo $this->Form->input('participants.' . $i . '.telephone', ['value' => $_participant->telephone]);
echo $this->Form->input('participants.' . $i . '.codePostal', ['value' => $_participant->codePostal]);
echo $this->Form->input('participants.' . $i . '.adresse', ['value' => $_participant->adresse]);
echo $this->Form->input('participants.' . $i . '.ville', ['value' => $_participant->ville]);?>
问题是如何在此表单中输入一个输入字段来指定参与者所属的商业选项。
感谢您的帮助。