You are here

function rng_add_event_form_display_defaults in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 rng.field.defaults.inc \rng_add_event_form_display_defaults()
  2. 8 rng.field.defaults.inc \rng_add_event_form_display_defaults()

Add field form defaults to a display entity.

Parameters

\Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display: A form display.

string $field_name: The field name.

Return value

\Drupal\Core\Entity\Display\EntityFormDisplayInterface The modified form display.

2 calls to rng_add_event_form_display_defaults()
EventTypeFieldMappingForm::createField in src/Form/EventTypeFieldMappingForm.php
Form submission function to respond to the create field button.
RngEventType::postSave in src/Entity/RngEventType.php
Acts on a saved entity before the insert or update hook is invoked.

File

./rng.field.defaults.inc, line 202
Creates field config if they do not exist.

Code

function rng_add_event_form_display_defaults(EntityFormDisplayInterface $form_display, $field_name = '') {
  switch ($field_name) {
    case EventManagerInterface::FIELD_REGISTRATION_TYPE:
      $form_display
        ->setComponent($field_name, [
        'type' => 'rng_registration_type',
      ]);
      break;
    case EventManagerInterface::FIELD_REGISTRATION_GROUPS:
      $form_display
        ->setComponent($field_name, [
        'type' => 'rng_registration_group',
      ]);
      break;
    case EventManagerInterface::FIELD_STATUS:
      $form_display
        ->setComponent($field_name, [
        'type' => 'boolean_checkbox',
      ]);
      break;
    case EventManagerInterface::FIELD_REGISTRANTS_CAPACITY:
      $form_display
        ->setComponent($field_name, [
        'type' => 'unlimited_number',
      ]);
      break;
    case EventManagerInterface::FIELD_WAIT_LIST:
      $form_display
        ->setComponent($field_name, [
        'type' => 'boolean_checkbox',
      ]);
      break;
    case EventManagerInterface::FIELD_EMAIL_REPLY_TO:
      $form_display
        ->setComponent($field_name, [
        'type' => 'email_default',
        'settings' => [
          'placeholder' => t('Leave empty to use site default.'),
        ],
      ]);
      break;
    case EventManagerInterface::FIELD_ALLOW_DUPLICATE_REGISTRANTS:
      $form_display
        ->setComponent($field_name, [
        'type' => 'boolean_checkbox',
      ]);
      break;
  }
  return $form_display;
}