Commit 12f44951 authored by Korko's avatar Korko
Browse files

Add prefix +33 and french flag for mobile to be clear about the number. Also...

Add prefix +33 and french flag for mobile to be clear about the number. Also handle 0 at the beginning.
parent 7d219bc4
......@@ -41,7 +41,7 @@ class RandomFormController extends Controller
$participants[$i] = [
'name' => $names[$i],
'email' => $emails[$i],
'phone' => $phones[$i],
'phone' => $phones[$i] ? str_pad($phones[$i], 10, '0', STR_PAD_LEFT) : $phones[$i],
'exclusions' => (isset($exclusions[$i])) ? array_map('intval', $exclusions[$i]) : [],
];
}
......
......@@ -45,7 +45,7 @@ class RandomFormRequest extends Request
foreach ($this->request->get('name') as $key => $name) {
$rules += [
'email.'.$key => 'required_without:phone.'.$key.'|email',
'phone.'.$key => 'required_without:email.'.$key.'|numeric|regex:#0[67]\d{8}#',
'phone.'.$key => 'required_without:email.'.$key.'|numeric|regex:#0?[67]\d{8}#',
'exclusions.'.$key => 'sometimes|array',
];
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -84,6 +84,21 @@ fieldset > div.form-group {
.participant .participant-remove-wrapper {
width: 179px;
}
.input-group-addon.lang {
padding: 6px 8px;
}
.input-group-addon.lang:before {
background-repeat: no-repeat;
background-image: url(../img/languages.png);
height: 11px;
width: 14px;
content: '';
display: inline-block;
margin-right: 8px;
}
.input-group-addon.lang[lang=fr]:before {
background-position: 0px -121px;
}
#mailContent, #mailPost {
max-width: 100%;
resize: none;
......
......@@ -141,12 +141,12 @@
<table id="participants" class="table table-hover table-striped table-numbered">
<thead>
<tr>
<th class="col-xs-3">@lang('form.participant.name')</th>
<th class="col-xs-3">@lang('form.participant.email')</th>
<th class="col-xs-0"></th>
<th class="col-xs-2 col-lg-2">@lang('form.participant.phone')</th>
<th class="col-xs-2">@lang('form.participant.exclusions')</th>
<th class="col-xs-1 col-lg-1"></th>
<th class="col-lg-3">@lang('form.participant.name')</th>
<th class="col-lg-3">@lang('form.participant.email')</th>
<th class="col-lg-0"></th>
<th class="col-lg-3">@lang('form.participant.phone')</th>
<th class="col-lg-2">@lang('form.participant.exclusions')</th>
<th class="col-lg-1"></th>
</tr>
</thead>
<tbody>
......@@ -168,7 +168,10 @@
@lang('form.mail-sms')
</td>
<td class="row border-right">
<input type='tel' pattern='0[67]\d{8}' maxlength="10" name="phone[]" placeholder="@lang('form.phone.placeholder')" v-model="phone" class="form-control participant-phone" :required="!email" />
<div class="input-group">
<span class="input-group-addon lang" lang="fr">(+33)</span>
<input type='tel' pattern='0?[67]\d{8}' :maxlength="(phone[0] === undefined || phone[0] === '0') ? 10 : 9" name="phone[]" placeholder="@lang('form.phone.placeholder')" v-model="phone" class="form-control participant-phone" :required="!email" />
</div>
</td>
<td class="row border-right text-left">
<select2 :options="participantNames" v-model="exclusions" placeholder="@lang('form.exclusions.placeholder')"></select2>
......
......@@ -76,7 +76,7 @@ class RequestTest extends TestCase
$content = $this->ajaxPost('/', ['name' => ['toto', 'tata'], 'phone' => ['0612345678', '55213249jgh']], 422);
$this->assertArrayKeysEquals(['g-recaptcha-response', 'phone.1', 'contentSMS'], $content);
$content = $this->ajaxPost('/', ['name' => ['toto', 'tata'], 'phone' => ['0612345678', '0612345678']], 422);
$content = $this->ajaxPost('/', ['name' => ['toto', 'tata'], 'phone' => ['0612345678', '612345678']], 422);
$this->assertArrayKeysEquals(['g-recaptcha-response', 'contentSMS'], $content);
}
......@@ -203,7 +203,7 @@ class RequestTest extends TestCase
'g-recaptcha-response' => 'mocked',
'name' => ['toto', 'tata', 'tutu'],
'email' => ['test@test.com', '', 'test2@test.com'],
'phone' => ['', '0612345678', '0712345678'],
'phone' => ['', '0612345678', '712345678'],
'exclusions' => [['2'], ['0'], ['1']],
'title' => 'test mail title',
'contentMail' => 'test mail {SANTA} => {TARGET}',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment