Closed paul121 closed 4 years ago
@jgaehring I just added another commit that allows the required
property to be false
if the provided timestamp
is null
. This lets me add a "Clear" button to my Date Range form that makes timestamp = null
. Without this change the date field would highlight red after clicking "Clear".
Because this all depends on sending the timestamp
as null
, I don't believe this is breaking in any way. Although it is a rather naive way of making the field optional - is there a better way to make the entire FarmDateTimeForm component optional?
Looks great!
Allow the date, hour and minute input fields to be empty if the provided
timestamp
isnull
. This improves behavior for forms where the date is optional - currently a nulltimestamp
is displayed asDec 31 1970
in the form. Once the user provides input, a newtimestamp
is provided.
So, I'm a little on the fence about this. Originally, the idea was to restrict null
or other invalid timestamps because this would be rejected by the server (see #158), but I can see how you wouldn't necessarily want to impose that restriction all the time.
Because this all depends on sending the
timestamp
asnull
, I don't believe this is breaking in any way. Although it is a rather naive way of making the field optional - is there a better way to make the entire FarmDateTimeForm component optional?
I think it might be better to have another prop, maybe something like :required="false"
but which would default to true
. That seems safer to me, but would still allow for flexibility if you wanted to disable it.
Added another commit with the required
prop. Gonna merge this in and push it out with 0.6.1 (#392).
Thanks @paul121! :clap:
Great! Thanks @jgaehring !
dateLabel
to replace the "Date" label of the component. This allows for multiple FarmDateTimeForm components to be added and labeled for their respective uses eg: "Start Date" and "End Date"timestamp
isnull
. This improves behavior for forms where the date is optional - currently a nulltimestamp
is displayed asDec 31 1970
in the form. Once the user provides input, a newtimestamp
is provided.id
to all form elements so that that multiple FarmDateTimeForm components have unique form elements on the same page. This fixes an issue where the AM/PM radio input was not unique to a single component. (@jgaehring I believe I implemented this correctly? Let me know if not!)