public function formField()
 {
     if (class_exists('FontAwesomeIconPickerField') && static::$use_icon_picker) {
         $icon = \FontAwesomeIconPickerField::create('use', _t('Shortcodable.ICON', 'Icon'));
         $icon->addExtraClass('icp--css-icon-shortcode')->setAttribute('data-placement', 'bottomLeft');
         if ($validIcons = HTMLEditorField::config()->valid_icon_shortcodes) {
             $icon->setAttribute('data-icons', json_encode(array_keys($validIcons)));
         }
     } else {
         if (HTMLEditorField::config()->valid_icon_shortcodes) {
             $icon = DropdownField::create('use', _t('Shortcodable.ICON', 'Icon'), Utilities::map_array_to_i18n(HTMLEditorField::config()->valid_icon_shortcodes, 'Icon'));
         } else {
             $icon = TextField::create('use', _t('Shortcodable.ICON', 'Icon'));
         }
     }
     if (HTMLEditorField::config()->prepend_icon) {
         $iconPrepend = ReadonlyField::create('prepend', _t('Shortcodable.ICON_PREPEND', 'Prepend'), HTMLEditorField::config()->prepend_icon);
     } else {
         $iconPrepend = TextField::create('prepend', _t('Shortcodable.ICON_PREPEND', 'Prepend'))->setAttribute('placeholder', static::$default_classes);
     }
     if (HTMLEditorField::config()->valid_icon_classes) {
         $iconClasses = DropdownField::create('classes', _t('Shortcodable.ICON_CLASSES', 'Classes'), array_combine(HTMLEditorField::config()->valid_icon_classes, HTMLEditorField::config()->valid_icon_classes));
     } else {
         $iconClasses = TextField::create('classes', _t('Shortcodable.ICON_CLASSES', 'Classes'));
     }
     return CompositeField::create(FieldList::create($icon, $iconPrepend, $iconClasses));
 }
 public function formField()
 {
     $shortcodes = Utilities::map_array_to_i18n(Member::config()->valid_shortcode_fields, 'Member');
     natsort($shortcodes);
     return CompositeField::create(FieldList::create(DropdownField::create('field', _t('Shortcodable.FIELD', 'Field'), $shortcodes), TextField::create('default', _t('Shortcodable.DEFAULT_VALUE', 'Default Value')), DropdownField::create('type', _t('Shortcodable.DISPLAY_TYPE', 'Display type'), ['' => 'Nice']), TextField::create('caption', _t('Shortcodable.CAPTION', 'Caption'))->setDescription(_t('Shortcodable.DESC-CAPTION', 'Only used for values that will resolve to links')), DropdownField::create('nolink', _t('Shortcodable.NO_AUTO_LINK', 'Autolink'), ['' => 'Yes', '1' => 'No'])));
 }
 public function testMapArrayToI18n()
 {
     $data = ['MyProperty' => 'Test'];
     $map = Utilities::map_array_to_i18n($data);
     $this->assertEquals('Test', $map['MyProperty']);
     i18n::get_translator('core')->getAdapter()->addTranslation(['_MilkywayUtilitiesTest.MyProperty' => 'MyProperty'], 'en_US');
     $map = Utilities::map_array_to_i18n($data, '_MilkywayUtilitiesTest');
     $this->assertEquals('MyProperty', $map['MyProperty']);
     i18n::get_translator('core')->getAdapter()->addTranslation(['_MilkywayUtilitiesTest.MyProperty' => 'MyProperty is {description}'], 'en_US');
     $map = Utilities::map_array_to_i18n($data, '_MilkywayUtilitiesTest', ['description' => 'awesome']);
     $this->assertEquals('MyProperty is awesome', $map['MyProperty']);
 }