我所处的环境是:会议可以具有一种或多种注册类型,而用户可以在会议中以一种或多种会议的注册类型进行注册。
因此,例如,ID为1的会议具有两种关联的注册类型,ID为1的注册类型为“ general”,而ID为2的“ plus”具有注册权。注册类型“加”没有任何自定义问题。
当用户在会议中进行注册并为注册类型“加”选择数量“ 2”并单击“下一步”时,用户将进入注册页面。在此页面中,有注册表格,用户只需输入其姓名和姓氏,然后单击“注册”。 $ request->全部显示如下,参与者的数组存储每个参与者的姓名,姓氏和注册类型:
array:4 [▼
"participant" => array:2 [▼
1 => array:3 [▼
"name" => "John"
"surname" => "W"
"rtypes" => "2"
]
2 => array:3 [▼
"name" => "Jake"
"surname" => "K"
"rtypes" => "2"
]
]
]
一切正常,所有信息都正确存储在数组中,然后可以将所有必要信息存储在数据库中。
疑问:
如果用户正在注册,并且为注册类型“常规”选择数量“ 2”,然后单击“下一步”,则注册类型“常规”具有2个与之相关的自定义问题。因此,在注册表格中,用户需要输入其姓名和姓氏,但用户还需要回答2个必需的自定义问题。我的疑问是如何为每个参与者存储自定义问题的答案,您知道如何正确实现吗?如下所示,仅存储参与者注册的姓名,姓氏和注册类型。但是如何还存储每个问题的答案?
array:4 [▼
"participant" => array:2 [▼
1 => array:3 [▼
"name" => "John"
"surname" => "W"
"rtypes" => "1"
]
2 => array:3 [▼
"name" => "Jake"
"surname" => "K"
"rtypes" => "1"
]
]
]
注册表格:
<form method="post"
action="https://proj.test/conference/1/conference-test/registration/storeRegistration">
<h6>Participant - 1 - general</h6>
<div class="form-group">
<label for="namegeneral_1"
class="text-gray">Name</label>
<input type="text" required id="namegeneral_1"
name="participant[name]"
class="form-control" value="">
</div>
<div class="form-group">
<label for="surnamegeneral_1"
class="text-gray">Surname</label>
<input type="text" required id="surnamegeneral_1"
class="form-control"
name="participant[surname]" value="">
</div>
<div class="form-group">
<label for="participant_question">Input text custom question</label>
<input type='text' name='participant[1][answer]' class='form-control' required>
<input type="hidden"
name="participant_question_required[]"
value="1">
<input type="hidden"
value="1"
name="participant[1][question_id]"/>
</div>
<div class="form-group">
<label for="participant_question">Long text custom question</label>
<textarea name='participant[1][answer]' class='form-control' rows='3' required></textarea>
<input type="hidden"
name="participant_question_required[]"
value="1">
<input type="hidden"
value="2"
name="participant[1][question_id]"/>
</div>
<input type="hidden" name="participant[1][rtypes]" value="1"/>
<h6>Participant - 2 - general</h6>
<div class="form-group">
<label for="namegeneral_2"
class="text-gray">Name</label>
<input type="text" required id="namegeneral_2"
name="participant[name]"
class="form-control" value="">
</div>
<div class="form-group">
<label for="surnamegeneral_2"
class="text-gray">Surname</label>
<input type="text" required id="surnamegeneral_2"
class="form-control"
name="participant[surname]" value="">
</div>
<div class="form-group">
<label for="participant_question">Input type text custom question</label>
<input type='text' name='participant[2][answer]' class='form-control' required>
<input type="hidden"
name="participant_question_required[]"
value="1">
<input type="hidden"
value="1"
name="participant[2][question_id]"/>
</div>
<div class="form-group">
<label for="participant_question">Long text custom question</label>
<textarea name='participant[2][answer]' class='form-control' rows='3' required></textarea>
<input type="hidden"
name="participant_question_required[]"
value="1">
<input type="hidden"
value="2"
name="participant[2][question_id]"/>
</div>
<input type="hidden" name="participant[2][rtypes]" value="1"/>
<input type="submit" class="btn btn-primary" value="Register"/>
</form>