在我的控制器中,我有以下代码:
$destinataires = [];
$destinataires[]= $emailclient;
for ($i = 1; $i <= 5; $i++)
{
$email = $request->request->get('emailclient'.$i);
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
$destinataires[] = $email;
}
}
当我将其用于表单(小枝)中的输入时,它将起作用:
{{ form_start(formUpload, { 'attr' : { 'class': 'batsendform', 'multipart' : true } }) }}
{{ form_row(formUpload.filepreview) }}<p id="batupload">Glissez le BAT 3D PDF ici.</p>
<div style="text-align: center;"><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#emailmodal">
Ajouter des destinataires
</button></div>
<!-- Modal -->
<div class="modal fade" id="emailmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel" style="color: black">Ajouter des emails destinataires du BAT</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<label style="color: black" for="emailclient1">Email 1 </label><input size="60" class="emailinput" type="email" name="emailclient1"> <br>
<label style="color: black" for="emailclient2">Email 2 </label><input size="60" class="emailinput" type="email" name="emailclient2"> <br>
<label style="color: black" for="emailclient3">Email 3 </label><input size="60" class="emailinput" type="email" name="emailclient3"> <br>
<label style="color: black" for="emailclient4">Email 4 </label><input size="60" class="emailinput" type="email" name="emailclient4"> <br>
<label style="color: black" for="emailclient5">Email 5 </label><input size="60" class="emailinput" type="email" name="emailclient5">
{{ form_end(formUpload) }}
但是我想从外部形式(树枝)使用这些值:
...
{{ form_start(formRefus) }}
<label style="text-align: center;color: red;">Laisser des précisions au client. (Optionnel)</label>
<textarea rows = "3" cols = "70" name = "messagegr"></textarea>
{{ form_row(formRefus.submit) }}
{{ form_end(formRefus) }}
在我的控制器中使用相同的方法:
$formRefus = $this->createForm(RefusClientType::class);
$formRefus->handleRequest($request);
if ($formRefus->isSubmitted() && $formRefus->isValid())
{
$destinataires = [];
$destinataires[]= $emailclient;
for ($i = 1; $i <= 5; $i++)
{
$email = $request->request->get('emailclient'.$i);
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
$destinataires[] = $email;
}
}
}
但是这次返回的值为零。 有谁有办法解决这个问题?谢谢:)