/** * @param Setting $setting * @param array $options * * @return string */ protected function getFieldType(Setting $setting, array &$options = array()) { $type = $setting->getType(); if ('radio' === $type) { $type = 'choice'; $options['expanded'] = true; $options['multiple'] = false; } if (in_array($type, array('choice', 'select2'))) { $settingOptions = $setting->getOptions(); $options['choices'] = $settingOptions; $options['choices_as_values'] = false; } return $type; }
/** * @param Setting $setting * @param array $options * * @return string */ protected function getFieldType(Setting $setting, array &$options = []) { $type = $setting->getType(); switch (strtolower($type)) { case 'select2': $type = Select2::class; $settingOptions = $setting->getOptions(); $options['choices'] = array_flip($settingOptions); $options['choices_as_values'] = true; break; case 'choice': $type = ChoiceType::class; $settingOptions = $setting->getOptions(); $options['choices'] = array_flip($settingOptions); $options['choices_as_values'] = true; break; case 'radio': $type = ChoiceType::class; $options['expanded'] = true; $options['multiple'] = false; $settingOptions = $setting->getOptions(); $options['choices'] = array_flip($settingOptions); $options['choices_as_values'] = true; break; case '': case 'text': $type = TextType::class; break; case 'email': $type = EmailType::class; break; case 'checkbox': $type = CheckboxType::class; break; case 'notification': $type = NotificationType::class; break; case 'image_upload': $type = ImageUpload::class; break; case 'password': $type = PasswordType::class; break; } return $type; }