Phone Input - option for simple text input (#207)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
6529907f2c
commit
4c56e8ba85
|
@ -190,6 +190,9 @@ class AnswerFormRequest extends FormRequest
|
||||||
}
|
}
|
||||||
return $this->getRulesForDate($property);
|
return $this->getRulesForDate($property);
|
||||||
case 'phone_number':
|
case 'phone_number':
|
||||||
|
if (isset($property['use_simple_text_input']) && $property['use_simple_text_input']) {
|
||||||
|
return ['string'];
|
||||||
|
}
|
||||||
return ['string', 'min:6', new ValidPhoneInputRule];
|
return ['string', 'min:6', new ValidPhoneInputRule];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -13,8 +13,12 @@ class ValidPhoneInputRule implements Rule
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
|
try {
|
||||||
return $phoneUtil->isValidNumber($phoneUtil->parse($value));
|
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
|
||||||
|
return $phoneUtil->isValidNumber($phoneUtil->parse($value));
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function message()
|
public function message()
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div :id="id ? id : name" :name="name" :style="inputStyle" class="flex items-center">
|
<div :id="id ? id : name" :name="name" :style="inputStyle" class="flex items-center">
|
||||||
<v-select class="w-[110px]" dropdown-class="w-[400px]" input-class="rounded-r-none" :data="countries"
|
<v-select class="w-[110px]" dropdown-class="w-[350px]" input-class="rounded-r-none" :data="countries"
|
||||||
v-model="selectedCountryCode"
|
v-model="selectedCountryCode"
|
||||||
:has-error="hasValidation && form.errors.has(name)"
|
:has-error="hasValidation && form.errors.has(name)"
|
||||||
:disabled="disabled" :searchable="true" :search-keys="['name']" :option-key="'code'" :color="color"
|
:disabled="disabled" :searchable="true" :search-keys="['name']" :option-key="'code'" :color="color"
|
||||||
|
|
|
@ -133,7 +133,7 @@ export default {
|
||||||
checkbox: 'CheckboxInput',
|
checkbox: 'CheckboxInput',
|
||||||
url: 'TextInput',
|
url: 'TextInput',
|
||||||
email: 'TextInput',
|
email: 'TextInput',
|
||||||
phone_number: 'PhoneInput'
|
phone_number: 'TextInput'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -159,6 +159,9 @@ export default {
|
||||||
if (field.type === 'signature') {
|
if (field.type === 'signature') {
|
||||||
return 'SignatureInput'
|
return 'SignatureInput'
|
||||||
}
|
}
|
||||||
|
if (field.type === 'phone_number' && !field.use_simple_text_input) {
|
||||||
|
return 'PhoneInput'
|
||||||
|
}
|
||||||
return this.fieldComponents[field.type]
|
return this.fieldComponents[field.type]
|
||||||
},
|
},
|
||||||
isPublicFormPage() {
|
isPublicFormPage() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default {
|
||||||
checkbox: 'CheckboxInput',
|
checkbox: 'CheckboxInput',
|
||||||
url: 'TextInput',
|
url: 'TextInput',
|
||||||
email: 'TextInput',
|
email: 'TextInput',
|
||||||
phone_number: 'PhoneInput'
|
phone_number: 'TextInput'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -57,6 +57,10 @@ export default {
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.property.type === 'phone_number' && !this.property.use_simple_text_input) {
|
||||||
|
componentData.component = 'PhoneInput'
|
||||||
|
}
|
||||||
|
|
||||||
if (['select', 'multi_select'].includes(this.property.type)) {
|
if (['select', 'multi_select'].includes(this.property.type)) {
|
||||||
componentData.multiple = false;
|
componentData.multiple = false;
|
||||||
componentData.options = this.property[this.property.type].options.map(option => {
|
componentData.options = this.property[this.property.type].options.map(option => {
|
||||||
|
|
|
@ -193,12 +193,18 @@
|
||||||
label="Field Name"
|
label="Field Name"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-checkbox v-model="field.hide_field_name" class="mb-3"
|
<v-checkbox v-model="field.hide_field_name" class="mt-3"
|
||||||
:name="field.id+'_hide_field_name'"
|
:name="field.id+'_hide_field_name'"
|
||||||
>
|
>
|
||||||
Hide field name
|
Hide field name
|
||||||
</v-checkbox>
|
</v-checkbox>
|
||||||
|
|
||||||
|
<v-checkbox v-model="field.use_simple_text_input" class="mt-3"
|
||||||
|
:name="field.id+'_use_simple_text_input'"
|
||||||
|
>
|
||||||
|
Use simple text input
|
||||||
|
</v-checkbox>
|
||||||
|
|
||||||
<!-- Pre-fill depends on type -->
|
<!-- Pre-fill depends on type -->
|
||||||
<v-checkbox v-if="field.type=='checkbox'" v-model="field.prefill" class="mt-3"
|
<v-checkbox v-if="field.type=='checkbox'" v-model="field.prefill" class="mt-3"
|
||||||
:name="field.id+'_prefill'"
|
:name="field.id+'_prefill'"
|
||||||
|
@ -216,7 +222,7 @@
|
||||||
:date-range="field.date_range===true"
|
:date-range="field.date_range===true"
|
||||||
label="Pre-filled value"
|
label="Pre-filled value"
|
||||||
/>
|
/>
|
||||||
<phone-input v-else-if="field.type === 'phone_number'"
|
<phone-input v-else-if="field.type === 'phone_number' && !field.use_simple_text_input"
|
||||||
name="prefill" class="mt-3"
|
name="prefill" class="mt-3"
|
||||||
:form="field" :can-only-country="true"
|
:form="field" :can-only-country="true"
|
||||||
label="Pre-filled value"
|
label="Pre-filled value"
|
||||||
|
|
Loading…
Reference in New Issue