I have a webform that has a Date Obtained field.
Label Form Key Type Value
Date Obtained date_obtained1 Date -
It is not required.
I have 2 other labels that are the same thing except Date Obtained 2/3 and date_obtained2/3, again not required.
Under the edit, I have the Day hidden, start date -30 years, and end date +2 years and a popup calendar enabled.
The issue I have is when this form is submitted, it gives me the following if the user doesn't select a date for the fields:
Month in Date Obtained is missing.
Year in Date Obtained is missing.
Month in Date Obtained 2 is missing.
Year in Date Obtained 2 is missing.
Month in Date Obtained 3 is missing.
Year in Date Obtained 3 is missing.
And will not submit the form.
Anyone have this before or know how to fix it? Thanks.
Dan
Comment | File | Size | Author |
---|---|---|---|
#18 | webform-non_required_partial_date-2612844 -17.patch | 1.57 KB | DanChadwick |
#10 | webform-non-required-date-field-error-2612844-10-7.x.patch | 1.79 KB | trzcinski.t@gmail.com |
|
Comments
Comment #2
dcamburn CreditAttribution: dcamburn commentedComment #3
DanChadwick CreditAttribution: DanChadwick commentedWebform does not support hiding the day. If you want to hide the day, you're going to have to write some more complicated javascript to include a day (e.g. 1) when month/year are present and not when it isn't.
Comment #4
dcamburn CreditAttribution: dcamburn commentedHide
Day
Month
Year
A hidden day or month will be set to 1. A hidden year will be set to the year of the default value.
And the Day is checked here. It doesn't show up on the webform as selectable, which is fine. The issue is that the user shouldn't have to select a month or year here since it is not required. However, it is forcing them to select such.
I'll assume that possibly someone already wrote some of the javascript that you are talking about on my site. I wasn't part of the original development.
Comment #5
dcamburn CreditAttribution: dcamburn commentedComment #6
DanChadwick CreditAttribution: DanChadwick commentedYes, you have some custom code. You'll need to find support for that outside the webform issue queue.
Comment #7
dcamburn CreditAttribution: dcamburn commentedDan, I don't mean to beat a dead horse: but maybe you can help out. I just downloaded the webform module to check all the files vs the original files. This is under webform\components\date.inc
$form['extra']['exclude'] = array(
'#type' => 'checkboxes',
'#title' => t('Hide'),
'#default_value' => $component['extra']['exclude'],
'#options' => array(
'day' => t('Day'),
'month' => t('Month'),
'year' => t('Year'),
),
'#description' => t('A hidden day or month will be set to 1. A hidden year will be set to the year of the default value.'),
'#weight' => 3,
);
That's exactly what the webform says and it looks like the ability to exclude the day, month, and year has been added. Any ideas?
Comment #8
DanChadwick CreditAttribution: DanChadwick commentedWow. My error. I had forgotten that this feature went in.
I suggest you don't use hiding the day until this bug is addressed.
Comment #9
AlinCut CreditAttribution: AlinCut as a volunteer commentedComment #10
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com as a volunteer commentedI have came across this issue as well.
It turns out that those are the lines that are responsible for the issue:
Basically when the day / month field is hidden - it gets automatically set to 1. Therefore if we leave other fields empty (even for non-required field) the condition is met, inner block is executed and error set.
To prevent that I have added a check - the value for the date part is only checked if this part is not hidden / excluded.
that helped but caused php notices in submit function - so I have added a few issets to submit function as well:
This worked for me.
Comment #11
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com as a volunteer commentedComment #12
humansky CreditAttribution: humansky as a volunteer commentedPatch in #10 works for me
Comment #13
CatherineOmega CreditAttribution: CatherineOmega as a volunteer commentedThe patch in #10 works for me as well.
Comment #14
arunkumarkThe patch #10 working fine for Webform 7.x-4.12.
Comment #15
Ramya Bala CreditAttribution: Ramya Bala commentedThe patch #10 works for me
Comment #16
Ramya Balasubramanian CreditAttribution: Ramya Balasubramanian commentedI have applied this patch #10 and its working fine.
Comment #18
DanChadwick CreditAttribution: DanChadwick commentedThanks for the patch. Great work.
I simplified the test a bit and removed the safety checks for #required. Also, I don't get the PHP notices you mention. Please re-open if you do with an explanation. I don't see why/how the day/month/year should be missing from the value array. They should be present but empty.
Committed to 7.x-4.x.
Comment #19
DanChadwick CreditAttribution: DanChadwick commentedComment #20
dcamburn CreditAttribution: dcamburn commentedThanks for the hard work on this guys!
Comment #21
fenstratClosing to clear out the old Webform 8.x-4.x branch. See #2827845: [roadmap] YAML Form 8.x-1.x to Webform 8.x-5.x.