function rng_add_event_form_display_defaults in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 rng.field.defaults.inc \rng_add_event_form_display_defaults()
- 3.x rng.field.defaults.inc \rng_add_event_form_display_defaults()
Add field form defaults to a display entity.
Parameters
EntityFormDisplayInterface $form_display: A form display.
string $field_name: The field name.
Return value
EntityFormDisplayInterface The modified form display.
2 calls to rng_add_event_form_display_defaults()
- EventType::postSave in src/
Entity/ EventType.php - Acts on a saved entity before the insert or update hook is invoked.
- EventTypeFieldMappingForm::createField in src/
Form/ EventTypeFieldMappingForm.php - Form submission function to respond to the create field button.
File
- ./
rng.field.defaults.inc, line 212 - 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, array(
'type' => 'boolean_checkbox',
));
break;
case EventManagerInterface::FIELD_CAPACITY:
$form_display
->setComponent($field_name, array(
'type' => 'unlimited_number',
));
break;
case EventManagerInterface::FIELD_EMAIL_REPLY_TO:
$form_display
->setComponent($field_name, array(
'type' => 'email_default',
'settings' => array(
'placeholder' => t('Leave empty to use site default.'),
),
));
break;
case EventManagerInterface::FIELD_ALLOW_DUPLICATE_REGISTRANTS:
$form_display
->setComponent($field_name, array(
'type' => 'boolean_checkbox',
));
break;
case EventManagerInterface::FIELD_REGISTRATION_REGISTRANTS_MINIMUM:
$form_display
->setComponent($field_name, array(
'type' => 'unlimited_number',
'settings' => [
'value_unlimited' => 0,
'label_unlimited' => t('No registrants required'),
'label_number' => t('Minimum'),
],
));
break;
case EventManagerInterface::FIELD_REGISTRATION_REGISTRANTS_MAXIMUM:
$form_display
->setComponent($field_name, array(
'type' => 'unlimited_number',
'settings' => [
'value_unlimited' => -1,
'label_unlimited' => t('No maximum'),
'label_number' => t('Maximum'),
],
));
break;
}
return $form_display;
}