public function FileLinkItem::fieldSettingsForm in File Link 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Field/FieldType/FileLinkItem.php \Drupal\file_link\Plugin\Field\FieldType\FileLinkItem::fieldSettingsForm()
Returns a form for the field-level settings.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure field-level settings.
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.
Return value
array The form definition for the field settings.
Overrides LinkItem::fieldSettingsForm
File
- src/
Plugin/ Field/ FieldType/ FileLinkItem.php, line 112
Class
- FileLinkItem
- Implements a 'file_link' plugin field type.
Namespace
Drupal\file_link\Plugin\Field\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = parent::fieldSettingsForm($form, $form_state);
// Make the extension list a little more human-friendly by comma-separation.
$extensions = str_replace(' ', ', ', $this
->getSetting('file_extensions'));
$element['file_extensions'] = [
'#type' => 'textfield',
'#title' => $this
->t('Allowed file extensions'),
'#default_value' => $extensions,
'#description' => $this
->t('Separate extensions with a space or comma and do not include the leading dot. Leave empty to allow any extension.'),
// Use the 'file' field type validator.
'#element_validate' => [
[
FileItem::class,
'validateExtensions',
],
],
'#maxlength' => 256,
];
$element['no_extension'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow URLs without file extension'),
'#description' => $this
->t('The link can refer a document such as a wiki page or a dynamic generated page that has no extension. Check this if you want to allow such URLs.'),
'#default_value' => $this
->getSetting('no_extension'),
];
return $element;
}