function paragraphs_library_form_paragraphs_type_form_alter

Implements hook_form_FORM_ID_alter().

File

paragraphs/modules/paragraphs_library/paragraphs_library.module, line 192
Main module file for the Paragraphs Library module.

Code

function paragraphs_library_form_paragraphs_type_form_alter(&$form, FormStateInterface $form_state) {

  // Adds paragraph type grouping to the form.

  /** @var \Drupal\paragraphs\ParagraphsTypeInterface $paragraph_type */
  $paragraph_type = $form_state
    ->getFormObject()
    ->getEntity();
  if ($paragraph_type
    ->id() != 'from_library') {
    $form['allow_library_conversion'] = [
      '#type' => 'checkbox',
      '#title' => t('Allow adding to library'),
      '#default_value' => $paragraph_type
        ->getThirdPartySetting('paragraphs_library', 'allow_library_conversion', FALSE),
    ];
    $form['#entity_builders'][] = 'paragraphs_library_form_paragraphs_type_form_builder';
  }
}