5 * Contains \Drupal\linkit\Plugin\Linkit\Attribute\Title.
8 namespace Drupal\linkit\Plugin\Linkit\Attribute;
10 use Drupal\Core\Form\FormStateInterface;
11 use Drupal\linkit\ConfigurableAttributeBase;
18 * label = @Translation("Title"),
19 * html_name = "title",
20 * description = @Translation("Basic input field for the title attribute.")
23 class Title extends ConfigurableAttributeBase {
28 public function buildFormElement($default_value) {
30 '#type' => 'textfield',
31 '#title' => t('Title'),
32 '#default_value' => $default_value,
35 '#placeholder' => t('The "title" attribute value'),
38 if ($this->configuration['automatic_title']) {
39 $element['#attached']['library'][] = 'linkit/linkit.attribute.title';
40 $element['#placeholder'] = t('The "title" attribute value (auto populated)');
49 public function defaultConfiguration() {
50 return parent::defaultConfiguration() + [
51 'automatic_title' => FALSE,
58 public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
59 $form['automatic_title'] = [
60 '#type' => 'checkbox',
61 '#title' => $this->t('Automatically populate title'),
62 '#default_value' => $this->configuration['automatic_title'],
63 '#description' => $this->t('Automatically populate the title attribute with the title from the match selection.'),
72 public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
78 public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
79 $this->configuration['automatic_title'] = $form_state->getValue('automatic_title');