You are here

function office_hours_form_field_storage_config_edit_form_alter in Office Hours 8

Implements hook_form_FORM_ID_alter().

Changes the Field_storage settings form to assure unlimited cardinality.

File

./office_hours.module, line 124
Creates a field and widget for inserting working or office hours per day.

Code

function office_hours_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  if ($entity
    ->getType() == 'office_hours') {
    $form['cardinality_container']['cardinality'] = [
      '#options' => [
        FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED => t('Unlimited'),
      ],
      '#default_value' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
      '#description' => '<p>' . t("This is unlimited by this field's nature. See\n      'Number of slots' for limiting the number of slots per day."),
    ] + $form['cardinality_container']['cardinality'];
  }
}