public function FileItem::storageSettingsForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::storageSettingsForm()
Returns a form for the storage-level settings.
Invoked from \Drupal\field_ui\Form\FieldStorageConfigEditForm to allow administrators to configure storage-level settings.
Field storage might reject settings changes that affect the field storage schema if the storage already has data. When the $has_data parameter is TRUE, the form should not allow changing the settings that take part in the schema() method. It is recommended to set #access to FALSE on the corresponding elements.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.
bool $has_data: TRUE if the field already has data, FALSE if not.
Return value
The form definition for the field settings.
Overrides EntityReferenceItem::storageSettingsForm
1 method overrides FileItem::storageSettingsForm()
- ImageItem::storageSettingsForm in core/
modules/ image/ src/ Plugin/ Field/ FieldType/ ImageItem.php - Returns a form for the storage-level settings.
File
- core/
modules/ file/ src/ Plugin/ Field/ FieldType/ FileItem.php, line 114 - Contains \Drupal\file\Plugin\Field\FieldType\FileItem.
Class
- FileItem
- Plugin implementation of the 'file' field type.
Namespace
Drupal\file\Plugin\Field\FieldTypeCode
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
$element = array();
$element['#attached']['library'][] = 'file/drupal.file';
$element['display_field'] = array(
'#type' => 'checkbox',
'#title' => t('Enable <em>Display</em> field'),
'#default_value' => $this
->getSetting('display_field'),
'#description' => t('The display option allows users to choose if a file should be shown when viewing the content.'),
);
$element['display_default'] = array(
'#type' => 'checkbox',
'#title' => t('Files displayed by default'),
'#default_value' => $this
->getSetting('display_default'),
'#description' => t('This setting only has an effect if the display option is enabled.'),
'#states' => array(
'visible' => array(
':input[name="settings[display_field]"]' => array(
'checked' => TRUE,
),
),
),
);
$scheme_options = \Drupal::service('stream_wrapper_manager')
->getNames(StreamWrapperInterface::WRITE_VISIBLE);
$element['uri_scheme'] = array(
'#type' => 'radios',
'#title' => t('Upload destination'),
'#options' => $scheme_options,
'#default_value' => $this
->getSetting('uri_scheme'),
'#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
'#disabled' => $has_data,
);
return $element;
}