Problem/Motivation
I'm seeing another set of date options over Form even when I explicitly configure the widget with Option show_extra in FALSE
Steps to reproduce
- Add to your node a new Smart date range
- Configured it as required, To the default date value set - None - and configure all the other required config fields and also configure it as unlimited values
- Configure the field to use Smart date and time range widget :
- Always include an empty widget = FALSE,
- Hide the end date field unless it's different from the start date. = FALSE,
- Provide a checkbox to make an event all day. = TRUE,
- Remove any seconds, if present, from existing values. = FALSE,
- Use modal for managing instances = TRUE
- Now Go and create a new node and add values to the date Field (The field should look ok, only one set of date fields) and save your node
- Now edit the node you just recently created , now your date field should show 2 rows of fields one with the values you just set and other completly empty .
Proposed resolution
From the file SmartDateWidgetBase.php starting at line 503:
// If configured and a default value set, suppress the extra input.
$field_default = $this->fieldDefinition->getDefaultValueLiteral();
$default_date_type = $field_default[0]['default_date_type'] ?? '';
if ($max > 0 && !$this->getSetting('show_extra') && $default_date_type) {
$max -= 1;
}
Specifically over this line:
if ($max > 0 && !$this->getSetting('show_extra') && $default_date_type) {
Remove the $default_date_type
variable from the condition.
So I have a question, why is important to check if the $default_date_type
variable is set to be able to hide the extra row using the show_extra flag