private function LinkitEditorDialog::addAttributes in Linkit 8.4
Adds the attributes enabled on the current profile.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
AttributeCollection $attributes: A collection of attributes for the current profile.
array $input: An array with the attribute values from the editor.
1 call to LinkitEditorDialog::addAttributes()
- LinkitEditorDialog::buildForm in src/
Form/ LinkitEditorDialog.php
File
- src/
Form/ LinkitEditorDialog.php, line 174 - Contains \Drupal\linkit\Form\LinkitEditorDialog.
Class
- LinkitEditorDialog
- Provides a linkit dialog for text editors.
Namespace
Drupal\linkit\FormCode
private function addAttributes(array &$form, FormStateInterface &$form_state, AttributeCollection $attributes, array $input) {
if ($attributes
->count()) {
$form['linkit_attributes'] = [
'#type' => 'container',
'#title' => $this
->t('Attributes'),
'#weight' => '10',
];
/** @var \Drupal\linkit\AttributeInterface $plugin */
foreach ($attributes as $plugin) {
$plugin_name = $plugin
->getHtmlName();
$default_value = isset($input[$plugin_name]) ? $input[$plugin_name] : '';
$form['linkit_attributes'][$plugin_name] = $plugin
->buildFormElement($default_value);
$form['linkit_attributes'][$plugin_name] += [
'#parents' => [
'attributes',
$plugin_name,
],
];
}
}
}