Пример #1
0
">
                                <select class="chosen form-control" id="available_filters">
                                    <option value=""></option>
                                    <?php 
foreach ($fields as $object => $field) {
    $header = $object;
    $icon = $object == 'company' ? 'fa-building' : 'fa-user';
    ?>
                                    <optgroup label="<?php 
    echo $view['translator']->trans('mautic.lead.' . $header);
    ?>
">
                                        <?php 
    foreach ($field as $value => $params) {
        $list = !empty($params['properties']['list']) ? $params['properties']['list'] : [];
        $choices = \Mautic\LeadBundle\Helper\FormFieldHelper::parseList($list);
        $object = $object;
        $list = json_encode($choices);
        $callback = !empty($params['properties']['callback']) ? $params['properties']['callback'] : '';
        $operators = !empty($params['operators']) ? $view->escape(json_encode($params['operators'])) : '{}';
        ?>
                                            <option value="<?php 
        echo $value;
        ?>
" id="available_<?php 
        echo $value;
        ?>
" data-field-object="<?php 
        echo $object;
        ?>
" data-field-type="<?php 
 private function getFormFields(FormBuilderInterface $builder, array $options, $object = 'lead')
 {
     $fieldValues = [];
     $isObject = false;
     if (!empty($options['data'])) {
         $isObject = is_object($options['data']);
         $fieldValues = $isObject ? $options['data']->getFields() : $options['data'];
     }
     $mapped = !$isObject;
     foreach ($options['fields'] as $field) {
         if ($field['isPublished'] === false || $field['object'] !== $object) {
             continue;
         }
         $attr = ['class' => 'form-control'];
         $properties = $field['properties'];
         $type = $field['type'];
         $required = $isObject ? $field['isRequired'] : false;
         $alias = $field['alias'];
         $group = $field['group'];
         if ($field['isUniqueIdentifer']) {
             $attr['data-unique-identifier'] = $field['alias'];
         }
         if ($isObject) {
             $value = isset($fieldValues[$group][$alias]['value']) ? $fieldValues[$group][$alias]['value'] : $field['defaultValue'];
         } else {
             $value = isset($fieldValues[$alias]) ? $fieldValues[$alias] : '';
         }
         $constraints = [];
         if ($required && empty($options['ignore_required_constraints'])) {
             $constraints[] = new NotBlank(['message' => 'mautic.lead.customfield.notblank']);
         }
         switch ($type) {
             case 'number':
                 if (empty($properties['precision'])) {
                     $properties['precision'] = null;
                 } else {
                     $properties['precision'] = (int) $properties['precision'];
                 }
                 if ('' === $value) {
                     // Prevent transform errors
                     $value = null;
                 }
                 $builder->add($alias, $type, ['required' => $required, 'label' => $field['label'], 'label_attr' => ['class' => 'control-label'], 'attr' => $attr, 'data' => null !== $value ? (double) $value : $value, 'mapped' => $mapped, 'constraints' => $constraints, 'precision' => $properties['precision'], 'rounding_mode' => isset($properties['roundmode']) ? (int) $properties['roundmode'] : 0]);
                 break;
             case 'date':
             case 'datetime':
             case 'time':
                 $attr['data-toggle'] = $type;
                 $opts = ['required' => $required, 'label' => $field['label'], 'label_attr' => ['class' => 'control-label'], 'widget' => 'single_text', 'attr' => $attr, 'mapped' => $mapped, 'input' => 'string', 'html5' => false, 'constraints' => $constraints];
                 if ($value) {
                     try {
                         $dtHelper = new DateTimeHelper($value, null, 'local');
                     } catch (\Exception $e) {
                         // Rather return empty value than break the page
                         $value = null;
                     }
                 }
                 if ($type == 'datetime') {
                     $opts['model_timezone'] = 'UTC';
                     $opts['view_timezone'] = date_default_timezone_get();
                     $opts['format'] = 'yyyy-MM-dd HH:mm';
                     $opts['with_seconds'] = false;
                     $opts['data'] = !empty($value) ? $dtHelper->toLocalString('Y-m-d H:i:s') : null;
                 } elseif ($type == 'date') {
                     $opts['data'] = !empty($value) ? $dtHelper->toLocalString('Y-m-d') : null;
                 } else {
                     $opts['data'] = !empty($value) ? $dtHelper->toLocalString('H:i:s') : null;
                 }
                 $builder->add($alias, $type, $opts);
                 break;
             case 'select':
             case 'multiselect':
             case 'boolean':
                 $typeProperties = ['required' => $required, 'label' => $field['label'], 'label_attr' => ['class' => 'control-label'], 'attr' => $attr, 'mapped' => $mapped, 'multiple' => false, 'constraints' => $constraints];
                 $choiceType = 'choice';
                 $emptyValue = '';
                 if (in_array($type, ['select', 'multiselect']) && !empty($properties['list'])) {
                     $typeProperties['choices'] = FormFieldHelper::parseList($properties['list']);
                     $typeProperties['expanded'] = false;
                     $typeProperties['multiple'] = 'multiselect' === $type;
                 }
                 if ($type == 'boolean' && !empty($properties['yes']) && !empty($properties['no'])) {
                     $choiceType = 'yesno_button_group';
                     $typeProperties['expanded'] = true;
                     $typeProperties['yes_label'] = $properties['yes'];
                     $typeProperties['no_label'] = $properties['no'];
                     $typeProperties['attr'] = [];
                     $emptyValue = ' x ';
                     if ($value !== '' && $value !== null) {
                         $value = (int) $value;
                     }
                 }
                 $typeProperties['data'] = $type === 'multiselect' ? FormFieldHelper::parseList($value) : $value;
                 $typeProperties['empty_value'] = $emptyValue;
                 $builder->add($alias, $choiceType, $typeProperties);
                 break;
             case 'country':
             case 'region':
             case 'timezone':
             case 'locale':
                 switch ($type) {
                     case 'country':
                         $choices = FormFieldHelper::getCountryChoices();
                         break;
                     case 'region':
                         $choices = FormFieldHelper::getRegionChoices();
                         break;
                     case 'timezone':
                         $choices = FormFieldHelper::getTimezonesChoices();
                         break;
                     case 'locale':
                         $choices = FormFieldHelper::getLocaleChoices();
                         break;
                 }
                 $builder->add($alias, 'choice', ['choices' => $choices, 'required' => $required, 'label' => $field['label'], 'label_attr' => ['class' => 'control-label'], 'data' => $value, 'attr' => ['class' => 'form-control', 'data-placeholder' => $field['label']], 'mapped' => $mapped, 'multiple' => false, 'expanded' => false, 'constraints' => $constraints]);
                 break;
             default:
                 if ($type == 'lookup') {
                     $type = 'text';
                     $attr['data-toggle'] = 'field-lookup';
                     $attr['data-action'] = 'lead:fieldList';
                     $attr['data-target'] = $alias;
                     if (!empty($properties['list'])) {
                         $attr['data-options'] = $properties['list'];
                     }
                 }
                 $builder->add($alias, $type, ['required' => $field['isRequired'], 'label' => $field['label'], 'label_attr' => ['class' => 'control-label'], 'attr' => $attr, 'data' => $value, 'mapped' => $mapped, 'constraints' => $constraints]);
                 break;
         }
     }
 }
Пример #3
0
 /**
  * Get a list of field choices for filters.
  *
  * @return array
  */
 public function getChoiceFields()
 {
     $operators = ['text' => ['include' => ['=', '!=', 'empty', '!empty', 'like', '!like']], 'select' => ['include' => ['=', '!=', 'empty', '!empty', 'in', '!in']], 'bool' => ['include' => ['=', '!=']], 'default' => ['exclude' => ['in', '!in']], 'multiselect' => ['include' => ['in', '!in']]];
     //field choices
     $choices['lead'] = ['date_added' => ['label' => $this->translator->trans('mautic.core.date.added'), 'properties' => ['type' => 'date'], 'operators' => 'default', 'object' => 'lead'], 'date_identified' => ['label' => $this->translator->trans('mautic.lead.list.filter.date_identified'), 'properties' => ['type' => 'date'], 'operators' => 'default', 'object' => 'lead'], 'last_active' => ['label' => $this->translator->trans('mautic.lead.list.filter.last_active'), 'properties' => ['type' => 'date'], 'operators' => 'default', 'object' => 'lead'], 'owner_id' => ['label' => $this->translator->trans('mautic.lead.list.filter.owner'), 'properties' => ['type' => 'lookup_id', 'callback' => 'activateLeadFieldTypeahead'], 'operators' => 'text', 'object' => 'lead'], 'points' => ['label' => $this->translator->trans('mautic.lead.lead.event.points'), 'properties' => ['type' => 'number'], 'operators' => 'default', 'object' => 'lead'], 'leadlist' => ['label' => $this->translator->trans('mautic.lead.list.filter.lists'), 'properties' => ['type' => 'leadlist'], 'operators' => 'multiselect', 'object' => 'lead'], 'lead_email_received' => ['label' => $this->translator->trans('mautic.lead.list.filter.lead_email_received'), 'properties' => ['type' => 'lead_email_received'], 'operators' => ['include' => ['in', '!in']], 'object' => 'lead'], 'tags' => ['label' => $this->translator->trans('mautic.lead.list.filter.tags'), 'properties' => ['type' => 'tags'], 'operators' => 'multiselect', 'object' => 'lead'], 'dnc_bounced' => ['label' => $this->translator->trans('mautic.lead.list.filter.dnc_bounced'), 'properties' => ['type' => 'boolean', 'list' => [0 => $this->translator->trans('mautic.core.form.no'), 1 => $this->translator->trans('mautic.core.form.yes')]], 'operators' => 'bool', 'object' => 'lead'], 'dnc_unsubscribed' => ['label' => $this->translator->trans('mautic.lead.list.filter.dnc_unsubscribed'), 'properties' => ['type' => 'boolean', 'list' => [0 => $this->translator->trans('mautic.core.form.no'), 1 => $this->translator->trans('mautic.core.form.yes')]], 'operators' => 'bool', 'object' => 'lead'], 'dnc_bounced_sms' => ['label' => $this->translator->trans('mautic.lead.list.filter.dnc_bounced_sms'), 'properties' => ['type' => 'boolean', 'list' => [0 => $this->translator->trans('mautic.core.form.no'), 1 => $this->translator->trans('mautic.core.form.yes')]], 'operators' => 'bool', 'object' => 'lead'], 'dnc_unsubscribed_sms' => ['label' => $this->translator->trans('mautic.lead.list.filter.dnc_unsubscribed_sms'), 'properties' => ['type' => 'boolean', 'list' => [0 => $this->translator->trans('mautic.core.form.no'), 1 => $this->translator->trans('mautic.core.form.yes')]], 'operators' => 'bool', 'object' => 'lead'], 'hit_url' => ['label' => $this->translator->trans('mautic.lead.list.filter.visited_url'), 'properties' => ['type' => 'text'], 'operators' => ['include' => ['=', 'like']], 'object' => 'lead'], 'stage' => ['label' => $this->translator->trans('mautic.lead.lead.field.stage'), 'properties' => ['type' => 'stage'], 'operators' => ['include' => ['=', '!=']], 'object' => 'lead']];
     //get list of custom fields
     $fields = $this->em->getRepository('MauticLeadBundle:LeadField')->getEntities(['filter' => ['isListable' => true, 'isPublished' => true], 'orderBy' => 'f.object']);
     foreach ($fields as $field) {
         $type = $field->getType();
         $properties = $field->getProperties();
         $properties['type'] = $type;
         if (in_array($type, ['lookup', 'multiselect', 'boolean'])) {
             if ($type == 'boolean') {
                 //create a lookup list with ID
                 $properties['list'] = [0 => $properties['no'], 1 => $properties['yes']];
             } else {
                 $properties['callback'] = 'activateLeadFieldTypeahead';
             }
             $properties['list'] = isset($properties['list']) ? FormFieldHelper::formatList(FormFieldHelper::FORMAT_BAR, FormFieldHelper::parseList($properties['list'])) : '';
         }
         $choices[$field->getObject()][$field->getAlias()] = ['label' => $field->getLabel(), 'properties' => $properties, 'object' => $field->getObject()];
         // Set operators allowed
         if ($type == 'boolean') {
             $choices[$field->getObject()][$field->getAlias()]['operators'] = 'bool';
         } elseif (in_array($type, ['select', 'multiselect', 'country', 'timezone', 'region', 'locale'])) {
             $choices[$field->getObject()][$field->getAlias()]['operators'] = 'select';
         } elseif (in_array($type, ['lookup', 'lookup_id', 'text', 'email', 'url', 'email', 'tel'])) {
             $choices[$field->getObject()][$field->getAlias()]['operators'] = 'text';
         } else {
             $choices[$field->getObject()][$field->getAlias()]['operators'] = 'default';
         }
     }
     foreach ($choices as $key => $choice) {
         $cmp = function ($a, $b) {
             return strcmp($a['label'], $b['label']);
         };
         uasort($choice, $cmp);
         $choices[$key] = $choice;
     }
     foreach ($choices as $object => $choiceObject) {
         foreach ($choiceObject as $key => $choice) {
             if (array_key_exists('operators', $choice) && is_string($choice['operators']) && array_key_exists($choice['operators'], $operators)) {
                 $choices[$object][$key]['operators'] = $operators[$choice['operators']];
             }
         }
     }
     return $choices;
 }
Пример #4
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('glue', 'choice', ['label' => false, 'choices' => ['and' => 'mautic.lead.list.form.glue.and', 'or' => 'mautic.lead.list.form.glue.or'], 'attr' => ['class' => 'form-control not-chosen glue-select', 'onchange' => 'Mautic.updateFilterPositioning(this)']]);
     $translator = $this->translator;
     $operatorChoices = $this->operatorChoices;
     $currentListId = $this->currentListId;
     $formModifier = function (FormEvent $event, $eventName) use($translator, $operatorChoices, $currentListId) {
         $data = $event->getData();
         $form = $event->getForm();
         $options = $form->getConfig()->getOptions();
         $fieldType = $data['type'];
         $fieldName = $data['field'];
         $type = 'text';
         $attr = ['class' => 'form-control'];
         $displayType = 'hidden';
         $displayAttr = [];
         $field = [];
         if (isset($options['fields']['lead'][$fieldName])) {
             $field = $options['fields']['lead'][$fieldName];
         } elseif (isset($options['fields']['company'][$fieldName])) {
             $field = $options['fields']['company'][$fieldName];
         }
         $customOptions = [];
         switch ($fieldType) {
             case 'leadlist':
                 if (!isset($data['filter'])) {
                     $data['filter'] = [];
                 } elseif (!is_array($data['filter'])) {
                     $data['filter'] = [$data['filter']];
                 }
                 // Don't show the current list ID in the choices
                 if (!empty($currentListId)) {
                     unset($options['lists'][$currentListId]);
                 }
                 $customOptions['choices'] = $options['lists'];
                 $customOptions['multiple'] = true;
                 $type = 'choice';
                 break;
             case 'lead_email_received':
                 if (!isset($data['filter'])) {
                     $data['filter'] = [];
                 } elseif (!is_array($data['filter'])) {
                     $data['filter'] = [$data['filter']];
                 }
                 $customOptions['choices'] = $options['emails'];
                 $customOptions['multiple'] = true;
                 $type = 'choice';
                 break;
             case 'tags':
                 if (!isset($data['filter'])) {
                     $data['filter'] = [];
                 } elseif (!is_array($data['filter'])) {
                     $data['filter'] = [$data['filter']];
                 }
                 $customOptions['choices'] = $options['tags'];
                 $customOptions['multiple'] = true;
                 $attr = array_merge($attr, ['data-placeholder' => $translator->trans('mautic.lead.tags.select_or_create'), 'data-no-results-text' => $translator->trans('mautic.lead.tags.enter_to_create'), 'data-allow-add' => 'true', 'onchange' => 'Mautic.createLeadTag(this)']);
                 $type = 'choice';
                 break;
             case 'stage':
                 $customOptions['choices'] = $options['stage'];
                 $type = 'choice';
                 break;
             case 'timezone':
             case 'country':
             case 'region':
             case 'locale':
                 switch ($fieldType) {
                     case 'timezone':
                         $choiceKey = 'timezones';
                         break;
                     case 'country':
                         $choiceKey = 'countries';
                         break;
                     case 'region':
                         $choiceKey = 'regions';
                         break;
                     case 'locale':
                         $choiceKey = 'locales';
                         break;
                 }
                 $type = 'choice';
                 $customOptions['choices'] = $options[$choiceKey];
                 $customOptions['multiple'] = in_array($data['operator'], ['in', '!in']);
                 if ($customOptions['multiple']) {
                     array_unshift($customOptions['choices'], ['' => '']);
                     if (!isset($data['filter'])) {
                         $data['filter'] = [];
                     }
                 }
                 break;
             case 'time':
             case 'date':
             case 'datetime':
                 $attr['data-toggle'] = $fieldType;
                 break;
             case 'lookup_id':
                 $type = 'hidden';
                 $displayType = 'text';
                 $displayAttr = array_merge($displayAttr, ['class' => 'form-control', 'data-toggle' => 'field-lookup', 'data-target' => $data['field'], 'data-action' => 'lead:fieldList', 'placeholder' => $translator->trans('mautic.lead.list.form.filtervalue')]);
                 if (isset($field['properties']['list'])) {
                     $displayAttr['data-options'] = $field['properties']['list'];
                 }
                 break;
             case 'select':
             case 'multiselect':
             case 'boolean':
                 $type = 'choice';
                 $attr = array_merge($attr, ['placeholder' => $translator->trans('mautic.lead.list.form.filtervalue')]);
                 if (in_array($data['operator'], ['in', '!in'])) {
                     $customOptions['multiple'] = true;
                     if (!isset($data['filter'])) {
                         $data['filter'] = [];
                     } elseif (!is_array($data['filter'])) {
                         $data['filter'] = [$data['filter']];
                     }
                 }
                 $list = $field['properties']['list'];
                 $choices = FormFieldHelper::parseList($list);
                 if ($fieldType == 'select') {
                     // array_unshift cannot be used because numeric values get lost as keys
                     $choices = array_reverse($choices, true);
                     $choices[''] = '';
                     $choices = array_reverse($choices, true);
                 }
                 $customOptions['choices'] = $choices;
                 break;
             case 'lookup':
             default:
                 $attr = array_merge($attr, ['data-toggle' => 'field-lookup', 'data-target' => $data['field'], 'data-action' => 'lead:fieldList', 'placeholder' => $translator->trans('mautic.lead.list.form.filtervalue')]);
                 if (isset($field['properties']['list'])) {
                     $attr['data-options'] = $field['properties']['list'];
                 }
                 break;
         }
         if (in_array($data['operator'], ['empty', '!empty'])) {
             $attr['disabled'] = 'disabled';
         } else {
             $customOptions['constraints'] = [new NotBlank(['message' => 'mautic.core.value.required'])];
         }
         // @todo implement in UI
         if (in_array($data['operator'], ['between', '!between'])) {
             $form->add('filter', 'collection', ['type' => $type, 'options' => ['label' => false, 'attr' => $attr], 'label' => false]);
         } else {
             $form->add('filter', $type, array_merge(['label' => false, 'attr' => $attr, 'data' => isset($data['filter']) ? $data['filter'] : '', 'error_bubbling' => false], $customOptions));
         }
         $form->add('display', $displayType, ['label' => false, 'attr' => $displayAttr, 'data' => $data['display'], 'error_bubbling' => false]);
         $choices = $operatorChoices;
         if (isset($field['operators']['include'])) {
             // Inclusive operators
             $choices = array_intersect_key($choices, array_flip($field['operators']['include']));
         } elseif (isset($field['operators']['exclude'])) {
             // Inclusive operators
             $choices = array_diff_key($choices, array_flip($field['operators']['exclude']));
         }
         $form->add('operator', 'choice', ['label' => false, 'choices' => $choices, 'attr' => ['class' => 'form-control not-chosen', 'onchange' => 'Mautic.convertLeadFilterInput(this)']]);
         if ($eventName == FormEvents::PRE_SUBMIT) {
             $event->setData($data);
         }
     };
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier) {
         $formModifier($event, FormEvents::PRE_SET_DATA);
     });
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($formModifier) {
         $formModifier($event, FormEvents::PRE_SUBMIT);
     });
     $builder->add('field', 'hidden');
     $builder->add('object', 'hidden');
     $builder->add('type', 'hidden');
 }
Пример #5
0
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function updateLeadFieldValuesAction(Request $request)
 {
     $alias = InputHelper::clean($request->request->get('alias'));
     $dataArray = ['success' => 0, 'options' => null];
     $leadField = $this->getModel('lead.field')->getRepository()->findOneBy(['alias' => $alias]);
     $choiceTypes = ['boolean', 'locale', 'country', 'region', 'lookup', 'timezone', 'select', 'radio'];
     if ($leadField && in_array($leadField->getType(), $choiceTypes)) {
         $properties = $leadField->getProperties();
         $leadFieldType = $leadField->getType();
         if (!empty($properties['list'])) {
             // Lookup/Select options
             $options = FormFieldHelper::parseList($properties['list']);
         } elseif (!empty($properties) && $leadFieldType == 'boolean') {
             // Boolean options
             $options = [0 => $properties['no'], 1 => $properties['yes']];
         } else {
             switch ($leadFieldType) {
                 case 'country':
                     $options = FormFieldHelper::getCountryChoices();
                     break;
                 case 'region':
                     $options = FormFieldHelper::getRegionChoices();
                     break;
                 case 'timezone':
                     $options = FormFieldHelper::getTimezonesChoices();
                     break;
                 case 'locale':
                     $options = FormFieldHelper::getLocaleChoices();
                     break;
                 default:
                     $options = !empty($properties) ? $properties : [];
             }
         }
         $dataArray['options'] = $options;
     }
     $dataArray['success'] = 1;
     return $this->sendJsonResponse($dataArray);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('field', 'leadfields_choices', ['label' => 'mautic.lead.campaign.event.field', 'label_attr' => ['class' => 'control-label'], 'multiple' => false, 'with_tags' => true, 'empty_value' => 'mautic.core.select', 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.lead.campaign.event.field_descr', 'onchange' => 'Mautic.updateLeadFieldValues(this)'], 'required' => true, 'constraints' => [new NotBlank(['message' => 'mautic.core.value.required'])]]);
     $leadModel = $this->factory->getModel('lead.lead');
     $fieldModel = $this->factory->getModel('lead.field');
     $operators = $leadModel->getFilterExpressionFunctions();
     $choices = [];
     foreach ($operators as $key => $operator) {
         $choices[$key] = $operator['label'];
     }
     $builder->add('operator', 'choice', ['choices' => $choices]);
     $ff = $builder->getFormFactory();
     // function to add 'template' choice field dynamically
     $func = function (FormEvent $e) use($ff, $fieldModel) {
         $data = $e->getData();
         $form = $e->getForm();
         $fieldValues = null;
         $fieldType = null;
         $choiceTypes = ['boolean', 'locale', 'country', 'region', 'lookup', 'timezone', 'select', 'radio'];
         if (isset($data['field'])) {
             $field = $fieldModel->getRepository()->findOneBy(['alias' => $data['field']]);
             if ($field) {
                 $properties = $field->getProperties();
                 $fieldType = $field->getType();
                 if (!empty($properties['list'])) {
                     // Lookup/Select options
                     $fieldValues = FormFieldHelper::parseList($properties['list']);
                 } elseif (!empty($properties) && $fieldType == 'boolean') {
                     // Boolean options
                     $fieldValues = [0 => $properties['no'], 1 => $properties['yes']];
                 } else {
                     switch ($fieldType) {
                         case 'country':
                             $fieldValues = FormFieldHelper::getCountryChoices();
                             break;
                         case 'region':
                             $fieldValues = FormFieldHelper::getRegionChoices();
                             break;
                         case 'timezone':
                             $fieldValues = FormFieldHelper::getTimezonesChoices();
                             break;
                         case 'locale':
                             $fieldValues = FormFieldHelper::getLocaleChoices();
                             break;
                         default:
                             if (!empty($properties)) {
                                 $fieldValues = $properties;
                             }
                     }
                 }
             }
         }
         // Display selectbox for a field with choices, textbox for others
         if (!empty($fieldValues) && in_array($fieldType, $choiceTypes)) {
             $form->add('value', 'choice', ['choices' => $fieldValues, 'label' => 'mautic.form.field.form.value', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control'], 'required' => true, 'constraints' => [new NotBlank(['message' => 'mautic.core.value.required'])]]);
         } else {
             $form->add('value', 'text', ['label' => 'mautic.form.field.form.value', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control'], 'required' => true, 'constraints' => [new NotBlank(['message' => 'mautic.core.value.required'])]]);
         }
     };
     // Register the function above as EventListener on PreSet and PreBind
     $builder->addEventListener(FormEvents::PRE_SET_DATA, $func);
     $builder->addEventListener(FormEvents::PRE_SUBMIT, $func);
 }