public function TestTextColorBehavior::buildBehaviorForm

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

paragraphs/tests/modules/paragraphs_test/src/Plugin/paragraphs/Behavior/TestTextColorBehavior.php, line 65

Class

TestTextColorBehavior
Provides a test feature plugin.

Namespace

Drupal\paragraphs_test\Plugin\paragraphs\Behavior

Code

public function buildBehaviorForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state) {
  $form['text_color'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Color'),
    '#maxlength' => 255,
    '#default_value' => $paragraph
      ->getBehaviorSetting($this
      ->getPluginId(), 'text_color', $this->configuration['default_color']),
    '#description' => $this
      ->t("Text color for the paragraph."),
  ];
  return $form;
}