function paragraphs_ee_form_paragraphs_type_form_alter in Paragraphs Editor Enhancements 8
Implements hook_form_BASE_FORM_ID_alter().
File
- ./
paragraphs_ee.module, line 240 - Main functions for "Paragraphs Editor Enhancements" module.
Code
function paragraphs_ee_form_paragraphs_type_form_alter(&$form, FormStateInterface $form_state, $form_id) {
/** @var Drupal\paragraphs\ParagraphsTypeInterface $paragraph */
$paragraph = $form_state
->getFormObject()
->getEntity();
/** @var \Drupal\paragraphs_ee\ParagraphsCategoryInterface[] $categories */
$categories = \Drupal::entityTypeManager()
->getStorage('paragraphs_category')
->loadMultiple();
// Sort the entities using the entity class's sort() method.
// See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
uasort($categories, [
ParagraphsCategory::class,
'sort',
]);
$form['paragraphs_categories'] = [
'#type' => 'checkboxes',
'#options' => array_combine(array_column($categories, 'id'), array_column($categories, 'label')),
'#title' => t('Paragraphs categories'),
'#description' => t('Select all categories the paragraph applies to.'),
'#default_value' => $paragraph
->getThirdPartySetting('paragraphs_ee', 'paragraphs_categories', []),
];
$form['#entity_builders'][] = 'paragraphs_ee_form_paragraphs_type_form_builder';
}