public function ParagraphsAnchorPlugin::buildBehaviorForm in Paragraphs Collection 8
Builds a behavior perspective for each paragraph based on its type.
This method is responsible for building the behavior form for each Paragraph so the user can set special attributes and properties.
Parameters
\Drupal\paragraphs\ParagraphInterface $paragraph: The paragraph.
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The fields build array that the plugin creates.
Overrides ParagraphsBehaviorBase::buildBehaviorForm
File
- modules/
paragraphs_collection_demo/ src/ Plugin/ paragraphs/ Behavior/ ParagraphsAnchorPlugin.php, line 81
Class
- ParagraphsAnchorPlugin
- Provides a Paragraphs Anchor plugin.
Namespace
Drupal\paragraphs_collection_demo\Plugin\paragraphs\BehaviorCode
public function buildBehaviorForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state) {
$form['anchor'] = [
'#type' => 'textfield',
'#title' => $this
->t('Anchor'),
'#description' => $this
->t('Sets an ID attribute prefixed with "scrollto-" in the Paragraph so that it can be used as a jump-to link.'),
'#default_value' => $paragraph
->getBehaviorSetting($this
->getPluginId(), 'anchor'),
];
return $form;
}