add model + form to handle alt names

This commit is contained in:
2020-01-30 15:51:39 +01:00
parent 7b7ce4a604
commit 426458811c
14 changed files with 482 additions and 2 deletions

View File

@@ -34,6 +34,8 @@ use Chill\MainBundle\Form\Type\Select2CountryType;
use Chill\MainBundle\Form\Type\Select2LanguageType;
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType;
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Form\Type\PersonAltNameType;
class PersonType extends AbstractType
{
@@ -46,14 +48,23 @@ class PersonType extends AbstractType
* @var string[]
*/
protected $config = array();
/**
*
* @var ConfigPersonAltNamesHelper
*/
protected $configAltNamesHelper;
/**
*
* @param string[] $personFieldsConfiguration configuration of visibility of some fields
*/
public function __construct(array $personFieldsConfiguration)
{
public function __construct(
array $personFieldsConfiguration,
ConfigPersonAltNamesHelper $configAltNamesHelper
) {
$this->config = $personFieldsConfiguration;
$this->configAltNamesHelper = $configAltNamesHelper;
}
/**
@@ -70,6 +81,12 @@ class PersonType extends AbstractType
'required' => true
));
if ($this->configAltNamesHelper->hasAltNames()) {
$builder->add('altNames', PersonAltNameType::class, [
'by_reference' => false
]);
}
if ($this->config['memo'] === 'visible') {
$builder
->add('memo', TextareaType::class, array('required' => false))