mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
fix deprecation error: use gqcn and pass option in array
This commit is contained in:
parent
1eeee615a3
commit
e021cea2da
@ -88,7 +88,8 @@ class CustomFieldChoice extends AbstractCustomField
|
|||||||
'multiple' => $customFieldOptions[self::MULTIPLE],
|
'multiple' => $customFieldOptions[self::MULTIPLE],
|
||||||
'choices' => array_combine(array_values($choices),array_keys($choices)),
|
'choices' => array_combine(array_values($choices),array_keys($choices)),
|
||||||
'required' => $customField->isRequired(),
|
'required' => $customField->isRequired(),
|
||||||
'label' => $this->translatableStringHelper->localize($customField->getName()));
|
'label' => $this->translatableStringHelper->localize($customField->getName())
|
||||||
|
);
|
||||||
|
|
||||||
//if allow_other = true
|
//if allow_other = true
|
||||||
if ($customFieldOptions[self::ALLOW_OTHER] == true) {
|
if ($customFieldOptions[self::ALLOW_OTHER] == true) {
|
||||||
@ -103,8 +104,10 @@ class CustomFieldChoice extends AbstractCustomField
|
|||||||
$builder
|
$builder
|
||||||
->create(
|
->create(
|
||||||
$customField->getSlug(),
|
$customField->getSlug(),
|
||||||
new ChoiceWithOtherType($otherValueLabel),
|
ChoiceWithOtherType::class,
|
||||||
$options)
|
$options,
|
||||||
|
array('other_value_label'=> $otherValueLabel)
|
||||||
|
)
|
||||||
->addModelTransformer(new CustomFieldDataTransformer($this, $customField)));
|
->addModelTransformer(new CustomFieldDataTransformer($this, $customField)));
|
||||||
|
|
||||||
} else { //if allow_other = false
|
} else { //if allow_other = false
|
||||||
|
@ -17,19 +17,12 @@ class ChoiceWithOtherType extends AbstractType
|
|||||||
{
|
{
|
||||||
private $otherValueLabel = 'Other value';
|
private $otherValueLabel = 'Other value';
|
||||||
|
|
||||||
public function __construct($otherValueLabel = Null) {
|
|
||||||
if($otherValueLabel) {
|
|
||||||
$this->otherValueLabel = $otherValueLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-PHPdoc)
|
/* (non-PHPdoc)
|
||||||
* @see \Symfony\Component\Form\AbstractType::buildForm()
|
* @see \Symfony\Component\Form\AbstractType::buildForm()
|
||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
|
||||||
//$otherValueLabel = $options['other_value_label'];
|
|
||||||
//add an 'other' entry in choices array
|
//add an 'other' entry in choices array
|
||||||
$options['choices'][$this->otherValueLabel] = '_other';
|
$options['choices'][$this->otherValueLabel] = '_other';
|
||||||
//ChoiceWithOther must always be expanded
|
//ChoiceWithOther must always be expanded
|
||||||
@ -52,9 +45,8 @@ class ChoiceWithOtherType extends AbstractType
|
|||||||
$resolver
|
$resolver
|
||||||
->setRequired(array('choices'))
|
->setRequired(array('choices'))
|
||||||
->setAllowedTypes('choices', array('array'))
|
->setAllowedTypes('choices', array('array'))
|
||||||
//->setDefault('other_value_label', null)
|
|
||||||
->setDefaults(array(
|
->setDefaults(array(
|
||||||
'multiple' => false,
|
'multiple' => false
|
||||||
))
|
))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user