Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-process date values #706

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from

Conversation

Healyhatman
Copy link

Given that a form is opened with Form::model
When using Form::date to create a date field and leaving the value null to fetch the value from the model, when the value is a Carbon then the value is not formatted, and is instead set as Y-m-d H:i:s causing the date to not be selected correctly. If you pass a carbon directly to the value (instead of null) then it is correctly formatted to Y-m-d.

This pull request pre-processes the value when it's null using getValueAttribute. Additionally, it replaces DateTime with DateTimeInterface to allow the use of CarbonImmutable etc

Given that a form is opened with Form::model
When using Form::date to create a date field and leaving the value null to fetch the value from the model, when the value is a Carbon then the value is set as Y-m-d H:i:s and the appropriate date is not selected. If you pass a carbon directly to the value (instead of null) then it is correctly formatted to Y-m-d.

This pull request pre-processes the value when it's null using getValueAttribute. Additionally, it replaces DateTime with DateTimeInterface to allow the use of CarbonImmutable
@Healyhatman
Copy link
Author

Fixes #703

@Healyhatman
Copy link
Author

Over a year and nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant