getgrav / getgrav/grav-plugin-form

Default values for date type fields inside elements: only 1st default value is set.

Open
#576 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
64
Forks
80
Avg merge
10h 13m
Merged PRs (30d)
9

Description

Hi all,

I have an issue regarding default values for date fields inside an elements field type.

The second date field (`date_end`) does not get the default value, only the first one (`date_start`).

JS is not complaining on console.

Any help please?

```
form:
validation: loose

fields:
...
scheduling.type:
type: elements
label: EVENTS_PLUGIN.FREQUENCY_LABEL
validate:
required: true
size: small
default: one-time
options:
one-time: EVENTS_PLUGIN.ONE_TIME_SELECT_OPTION
daily: EVENTS_PLUGIN.DAILY_SELECT_OPTION
...
fields:
one-time:
...
daily:
type: element
fields:
.date_start:
type: date
label: EVENTS_PLUGIN.START_DATE_LABEL
default: "2099-01-01"
validate:
required: true
.date_start_enabled:
type: hidden
value: true
.date_end:
type: date
label: EVENTS_PLUGIN.END_DATE_LABEL
default: "2099-01-01"
validate:
required: true
...
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the YAML configuration from the issue with an elements field containing the daily date_start and date_end fields. Trace how defaults are applied to nested element fields, then compare the handling of both date fields. Done means both date_start and date_end receive 2099-01-01 without console errors, with a regression test covering the configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.