Why must fields to add an event be required?

Created on 20 August 2024, 4 months ago
Updated 21 August 2024, 3 months ago

Problem/Motivation

This is a handy and easy to use setup for a basic reservation system. Thanks everybody for all the hard work!
I build a setup to make a reservation for a device. When they make a reservation, in fact they add an event.
I add some fields to the content type so they can add their name, email, phone, ...
All these fields are required and they appear on the add reservation page.
But I also added a field for remarks when they make a reservation. This field is not required and does not appear on the reservation form.
Is there a reason why they are disabled?

Steps to reproduce

Fields are disabled in the CalendarEventController.php in this part :

// Hide all fields that are irrelevant to the event date.
if (substr($name, 0, 6) === 'field_' && $name !== $start_field && $name !== $end_field && $name !== 'field_monthly_event' && $name !== 'field_weekly_event' && !$field_def[$name]->isRequired()) {
  $element['#access'] = FALSE;
  }

Why is !$field_def[$name]->isRequired() necessary in above code?

Proposed resolution

Can we override the class addEvent()? How to do that?
Or is there another way to make this fields appear?

✨ Feature request
Status

Closed: works as designed

Version

5.1

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium pascalmortier

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024