Closed (works as designed)
Project:
Driven API
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Nov 2010 at 23:16 UTC
Updated:
19 Nov 2010 at 12:31 UTC
If I use Driven NEP to disable modification of a CCK date field, submission of a node form (editing the node) fails validation, with the messsage "the date(s) are invalid". Perhaps this is related to my (solved) programmatic date comment_driven issue http://drupal.org/node/942932?
Comments
Comment #1
arhak commentedI need to know exactly how to reproduce it
I tried with dropdown widget and there was no trouble (date-6.x-2.4 but 2.6 doesn't look so different)
since NEP only turns #access into FALSE, it should work,
it is unobtrusive, and complies FAPI specs
PS: I might be missing something, this was just a quick trial
Comment #2
obrienmd commentedWill put together another trial to test the issue happening on a production setup ASAP. Thanks for the feedback, arhak.
Comment #3
obrienmd commentedOK, did some more testing. To reproduce:
1) Install vanilla Drupal 6.19
2) Add comment_driven (tested reccommended and 1.x-dev), driven (tested recommended and 1.x-dev), date modules (tested 2.4 and 2.6)
3) Add a content type with a date field (tested select list and text field w/ date popup)
4) Make the date field required
5) Turn on comment driven for the date field
6) Turn on NEP for the date field
For all permutations of the above tested parameters, editing the node after initial creation (ie: when the NEP date property is hidden) results in the error message "There are errors in : The dates are invalid." after submission.
Driving the property through comment driven works great.
Comment #4
obrienmd commentedIf I make the field not required, this problem no longer occurs - this leads me to believe it has something to do with checking if field is required in date's validation code.
Comment #5
arhak commentedconfiguration of the date field would be helpful (for instance, you don't mention its granularity)
the only place in the whole date module where that string exists is in date_elements.inc, near line 480
and it clearly says
if (!$field['required']) ...which is precisely the opposite of what you describe regarding making the field requiredComment #6
arhak commentedits really odd,
I'll have to try it in a fresh install
BTW, which value did you assigned to the date field on node creation?
PS: the date I tried in my test has
- Default value: blank
- Default value for To date: same as From date
- Years back and forward: -3:+3
- ... oh.. it is not required (then my test was not accurate)
- granularity up to the minute
Comment #7
arhak commentedindeed, making it required brings the error
Comment #8
arhak commentedas I previously said @#1,
Driven NEP only turns #access into FALSE
which leaves $element['#post'] without a $field_name index (near line 391)
while the return statement (near line 385) saves the situation for non-required dates
then, turning #access=FALSE makes $element['#post'][$field_name] undefined, then $posted is also undefined (which is already a bug, but doesn't causes the current issue)
and immediately bellow it $field results undefined too, since $form_state['#field_info'][$field_name] is also undefined (right now I won't look why it is, I guess it is part of date's submission workflow)
Note: $field_name and $element['#field_name'] hold the same value in my test, that is why I used them indistinctly in the above description
then, if $field is undefined the code @#5 triggers the error because
!$field['required']yields TRUEaccording to FAPI #access=FALSE should be supported by date module,
ergo, not our bug
PS: I recommend opening a new issue on the date module, because they wouldn't distinguish their fault mixed with Driven API
Comment #9
arhak commentedBTW for the date module my proposal would be the following
Comment #10
obrienmd commentedThanks, arhak.
Posted a new issue w/ patch to date at: http://drupal.org/node/976254
Comment #11
arhak commentedmoved to its actual project