mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Try to add placeholder
This commit is contained in:
parent
e1b3719746
commit
37e38436a8
@ -20,6 +20,7 @@ use Chill\MainBundle\Form\Type\PickCivilityType;
|
|||||||
use Chill\MainBundle\Form\Type\Select2CountryType;
|
use Chill\MainBundle\Form\Type\Select2CountryType;
|
||||||
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\PersonPhone;
|
use Chill\PersonBundle\Entity\PersonPhone;
|
||||||
@ -27,6 +28,13 @@ use Chill\PersonBundle\Form\Type\GenderType;
|
|||||||
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
||||||
use Chill\PersonBundle\Form\Type\PersonPhoneType;
|
use Chill\PersonBundle\Form\Type\PersonPhoneType;
|
||||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use libphonenumber\PhoneNumberFormat;
|
||||||
|
use libphonenumber\PhoneNumberType;
|
||||||
|
use libphonenumber\PhoneNumberUtil;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
@ -57,17 +65,21 @@ class PersonType extends AbstractType
|
|||||||
|
|
||||||
protected TranslatableStringHelper $translatableStringHelper;
|
protected TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
private ParameterBagInterface $parameterBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $personFieldsConfiguration configuration of visibility of some fields
|
* @param string[] $personFieldsConfiguration configuration of visibility of some fields
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
array $personFieldsConfiguration,
|
array $personFieldsConfiguration,
|
||||||
ConfigPersonAltNamesHelper $configAltNamesHelper,
|
ConfigPersonAltNamesHelper $configAltNamesHelper,
|
||||||
TranslatableStringHelper $translatableStringHelper
|
TranslatableStringHelperInterface $translatableStringHelper,
|
||||||
|
ParameterBagInterface $parameterBag
|
||||||
) {
|
) {
|
||||||
$this->config = $personFieldsConfiguration;
|
$this->config = $personFieldsConfiguration;
|
||||||
$this->configAltNamesHelper = $configAltNamesHelper;
|
$this->configAltNamesHelper = $configAltNamesHelper;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
$this->parameterBag = $parameterBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
@ -126,15 +138,43 @@ class PersonType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('visible' === $this->config['phonenumber']) {
|
if ('visible' === $this->config['phonenumber']) {
|
||||||
$builder->add('phonenumber', TelType::class, [
|
$examplePhoneNumber = PhoneNumberUtil::getInstance()
|
||||||
'required' => false,
|
->getExampleNumberForType(
|
||||||
// 'placeholder' => '+33623124554' //TODO placeholder for phone numbers
|
$this->parameterBag->get('chill_main.phone_helper')['default_carrier_code'],
|
||||||
]);
|
PhoneNumberType::FIXED_LINE
|
||||||
|
);
|
||||||
|
|
||||||
|
$builder
|
||||||
|
->add(
|
||||||
|
'phonenumber',
|
||||||
|
TelType::class,
|
||||||
|
[
|
||||||
|
'required' => false,
|
||||||
|
'attr' => [
|
||||||
|
'placeholder' => PhoneNumberUtil::getInstance()->format($examplePhoneNumber, PhoneNumberFormat::NATIONAL)
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('visible' === $this->config['mobilenumber']) {
|
if ('visible' === $this->config['mobilenumber']) {
|
||||||
|
$examplePhoneNumber = PhoneNumberUtil::getInstance()
|
||||||
|
->getExampleNumberForType(
|
||||||
|
$this->parameterBag->get('chill_main.phone_helper')['default_carrier_code'],
|
||||||
|
PhoneNumberType::MOBILE
|
||||||
|
);
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('mobilenumber', TelType::class, ['required' => false])
|
->add(
|
||||||
|
'mobilenumber',
|
||||||
|
TelType::class,
|
||||||
|
[
|
||||||
|
'required' => false,
|
||||||
|
'attr' => [
|
||||||
|
'placeholder' => PhoneNumberUtil::getInstance()->format($examplePhoneNumber, PhoneNumberFormat::NATIONAL)
|
||||||
|
],
|
||||||
|
]
|
||||||
|
)
|
||||||
->add('acceptSMS', CheckboxType::class, [
|
->add('acceptSMS', CheckboxType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
Chill\PersonBundle\Form\:
|
Chill\PersonBundle\Form\:
|
||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
resource: '../../Form/'
|
resource: '../../Form/'
|
||||||
|
|
||||||
Chill\PersonBundle\Form\PersonType:
|
Chill\PersonBundle\Form\PersonType:
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
arguments:
|
arguments:
|
||||||
$personFieldsConfiguration: '%chill_person.person_fields%'
|
$personFieldsConfiguration: '%chill_person.person_fields%'
|
||||||
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
||||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: '@chill.person.form.person_creation' }
|
- { name: form.type, alias: '@chill.person.form.person_creation' }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user