public static function ParagraphsFeatures::getThirdPartyForm in Paragraphs Features 8
Same name and namespace in other branches
- 2.x src/ParagraphsFeatures.php \Drupal\paragraphs_features\ParagraphsFeatures::getThirdPartyForm()
Get 3rd party setting form for paragraphs features.
Parameters
\Drupal\Core\Field\WidgetInterface $plugin: Widget plugin.
string $field_name: Field name.
Return value
array Returns 3rd party form elements.
1 call to ParagraphsFeatures::getThirdPartyForm()
File
- src/
ParagraphsFeatures.php, line 111
Class
- ParagraphsFeatures
- Paragraphs features class.
Namespace
Drupal\paragraphs_featuresCode
public static function getThirdPartyForm(WidgetInterface $plugin, $field_name) {
$elements = [];
$elements['delete_confirmation'] = [
'#type' => 'checkbox',
'#title' => t('Enable confirmation on paragraphs remove'),
'#default_value' => $plugin
->getThirdPartySetting('paragraphs_features', 'delete_confirmation'),
'#attributes' => [
'class' => [
'paragraphs-features__delete-confirmation__option',
],
],
];
// Define rule for enabling/disabling options that depend on modal add mode.
$modal_related_options_rule = [
':input[name="fields[' . $field_name . '][settings_edit_form][settings][add_mode]"]' => [
'value' => 'modal',
],
];
$elements['add_in_between'] = [
'#type' => 'checkbox',
'#title' => t('Enable add in between buttons'),
'#default_value' => $plugin
->getThirdPartySetting('paragraphs_features', 'add_in_between'),
'#attributes' => [
'class' => [
'paragraphs-features__add-in-between__option',
],
],
'#states' => [
'enabled' => $modal_related_options_rule,
'visible' => $modal_related_options_rule,
],
];
$elements['split_text'] = [
'#type' => 'checkbox',
'#title' => t('Enable split text for text paragraphs'),
'#default_value' => $plugin
->getThirdPartySetting('paragraphs_features', 'split_text'),
'#attributes' => [
'class' => [
'paragraphs-features__split-text__option',
],
],
'#states' => [
'enabled' => $modal_related_options_rule,
'visible' => $modal_related_options_rule,
],
];
// Only show the drag & drop feature if we can find the sortable library.
$library_discovery = \Drupal::service('library.discovery');
$library = $library_discovery
->getLibraryByName('paragraphs', 'paragraphs-dragdrop');
$elements['show_drag_and_drop'] = [
'#type' => 'checkbox',
'#title' => t('Show drag & drop button'),
'#default_value' => $plugin
->getThirdPartySetting('paragraphs_features', 'show_drag_and_drop', TRUE),
'#access' => !empty($library),
];
return $elements;
}