/** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $field_settings = $this->getSettings(); $embridge_settings = \Drupal::config('embridge.settings'); /** @var EmbridgeCatalog[] $entities */ $entities = EmbridgeCatalog::loadMultiple(); $options = []; foreach ($entities as $entity) { $options[$entity->id()] = $entity->label(); } $element['catalog_id'] = array('#type' => 'select', '#title' => t('Catalog'), '#default_value' => $field_settings['catalog_id'], '#options' => $options, '#description' => t("Select the Catalog to source media from for this field."), '#required' => TRUE, '#weight' => 6); $libraries_admin = Link::fromTextAndUrl('libraries admin', Url::fromUri($embridge_settings->get('uri') . '/' . $field_settings['catalog_id'] . '/views/modules/library/index.html')); $element['library_id'] = array('#type' => 'textfield', '#title' => t('Library'), '#default_value' => $field_settings['library_id'], '#description' => t("Limit uploads via this field to a specific library. This will also provide a default library on the asset search advanced filter. To identify the library ID, select the library on the @libraries_admin page and note the ID.", ['@libraries_admin' => $libraries_admin->toString()]), '#required' => FALSE, '#size' => 10, '#weight' => 6); $element['allow_search'] = array('#type' => 'checkbox', '#title' => t('Allow search'), '#default_value' => $field_settings['allow_search'], '#description' => t("Check this to allow users to search EMDB for existing assets, requires <em>search embridge assets</em> permission."), '#weight' => 6); return $element + parent::fieldSettingsForm($form, $form_state); }
/** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { // Get base form from FileItem. $element = parent::fieldSettingsForm($form, $form_state); $settings = $this->getSettings(); // Add maximum and minimum resolution settings. $max_resolution = explode('x', $settings['max_resolution']) + array('', ''); $element['max_resolution'] = array('#type' => 'item', '#title' => t('Maximum image resolution'), '#element_validate' => array(array(get_class($this), 'validateResolution')), '#weight' => 4.1, '#field_prefix' => '<div class="container-inline">', '#field_suffix' => '</div>', '#description' => t('The maximum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height. Resizing images on upload will cause the loss of <a href="http://wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.')); $element['max_resolution']['x'] = array('#type' => 'number', '#title' => t('Maximum width'), '#title_display' => 'invisible', '#default_value' => $max_resolution[0], '#min' => 1, '#field_suffix' => ' × '); $element['max_resolution']['y'] = array('#type' => 'number', '#title' => t('Maximum height'), '#title_display' => 'invisible', '#default_value' => $max_resolution[1], '#min' => 1, '#field_suffix' => ' ' . t('pixels')); $min_resolution = explode('x', $settings['min_resolution']) + array('', ''); $element['min_resolution'] = array('#type' => 'item', '#title' => t('Minimum image resolution'), '#element_validate' => array(array(get_class($this), 'validateResolution')), '#weight' => 4.2, '#field_prefix' => '<div class="container-inline">', '#field_suffix' => '</div>', '#description' => t('The minimum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a smaller image is uploaded, it will be rejected.')); $element['min_resolution']['x'] = array('#type' => 'number', '#title' => t('Minimum width'), '#title_display' => 'invisible', '#default_value' => $min_resolution[0], '#min' => 1, '#field_suffix' => ' × '); $element['min_resolution']['y'] = array('#type' => 'number', '#title' => t('Minimum height'), '#title_display' => 'invisible', '#default_value' => $min_resolution[1], '#min' => 1, '#field_suffix' => ' ' . t('pixels')); // Remove the description option. unset($element['description_field']); // Add title and alt configuration options. $element['alt_field'] = array('#type' => 'checkbox', '#title' => t('Enable <em>Alt</em> field'), '#default_value' => $settings['alt_field'], '#description' => t('The alt attribute may be used by search engines, screen readers, and when the image cannot be loaded. Enabling this field is recommended.'), '#weight' => 9); $element['alt_field_required'] = array('#type' => 'checkbox', '#title' => t('<em>Alt</em> field required'), '#default_value' => $settings['alt_field_required'], '#description' => t('Making this field required is recommended.'), '#weight' => 10, '#states' => array('visible' => array(':input[name="settings[alt_field]"]' => array('checked' => TRUE)))); $element['title_field'] = array('#type' => 'checkbox', '#title' => t('Enable <em>Title</em> field'), '#default_value' => $settings['title_field'], '#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image. Enabling this field is not recommended as it can cause problems with screen readers.'), '#weight' => 11); $element['title_field_required'] = array('#type' => 'checkbox', '#title' => t('<em>Title</em> field required'), '#default_value' => $settings['title_field_required'], '#weight' => 12, '#states' => array('visible' => array(':input[name="settings[title_field]"]' => array('checked' => TRUE)))); // Add default_image element. static::defaultImageForm($element, $settings); $element['default_image']['#description'] = t("If no image is uploaded, this image will be shown on display and will override the field's default image."); return $element; }
/** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { // Get base form from FileItem. $element = parent::fieldSettingsForm($form, $form_state); // Remove the description option. unset($element['description_field']); unset($element['file_directory']); unset($element['file_extensions']); unset($element['max_filesize']); return $element; }