public function AddToCopyForm::buildForm in Add link to copied text 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Forms/ AddToCopyForm.php, line 30
Class
- AddToCopyForm
- Provides a configuration form for addtocopy settings.
Namespace
Drupal\addtocopy\FormsCode
public function buildForm(array $form, FormStateInterface $form_state) {
$addtocopy_config = $this
->config('addtocopy.settings');
$form['addtocopy_selector'] = array(
'#type' => 'textfield',
'#title' => t('jQuery selector'),
'#default_value' => $addtocopy_config
->get('addtocopy.selector') ? $addtocopy_config
->get('addtocopy.selector') : '#content',
'#description' => t('jQuery selector expression to apply Add to Copy.'),
'#required' => TRUE,
);
$form['addtocopy_minlen'] = array(
'#type' => 'textfield',
'#title' => t('Minimum text length'),
'#default_value' => $addtocopy_config
->get('addtocopy.minlen') ? $addtocopy_config
->get('addtocopy.minlen') : '25',
'#description' => t('Minimum selected text length to activate Add to Copy.'),
'#required' => TRUE,
);
$form['addtocopy_htmlcopytxt'] = array(
'#type' => 'textfield',
'#title' => t('HTML to add to selected text'),
'#default_value' => $addtocopy_config
->get('addtocopy.htmlcopytxt') ? $addtocopy_config
->get('addtocopy.htmlcopytxt') : '<br>More: <a href="[link]">[link]</a><br>',
'#description' => t('[link] will be replaced with the current page link.'),
'#required' => TRUE,
);
$form['addtocopy_addcopyfirst'] = array(
'#type' => 'radios',
'#title' => t('Add before or after selected text'),
'#options' => array(
0 => t('After'),
1 => t('Before'),
),
'#default_value' => $addtocopy_config
->get('addtocopy.addcopyfirst') ? $addtocopy_config
->get('addtocopy.addcopyfirst') : '0',
'#description' => t('jQuery selector expression to apply Add to Copy.'),
'#required' => TRUE,
);
return parent::buildForm($form, $form_state);
}