Closed (fixed)
Project:
Flexinode
Version:
master
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
15 Mar 2006 at 18:39 UTC
Updated:
13 May 2006 at 23:31 UTC
Jump to comment: Most recent file
If I add a date field to a content type and make it required, it never validates even when it's filled in. I always get an error saying "You must enter a date" (or whatever the exact wording is).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 54215_2.patch | 1.49 KB | samc |
| #1 | 54215.patch | 1.24 KB | samc |
Comments
Comment #1
samc commentedProblem here is that in general flexinode fields put data in $node->$fieldname, e.g. $node->flexinode_X. But timestamp doesn't. It uses a bunch of other fields to represent the individual parts of the date, e.g. $node->flexinode_X_year.
Because the validation routine in flexinode.module just checks for existence of $node->$fieldname, validation for this field always fails when it's required.
To fix, I added a hidden field to the form generated by flexinode_field_timestamp_form(), which in turn sets $node->flexinode_X equal to 1, allowing the field to validate when required.
This feels a wee bit hackish to me, but it allows the fix to remain contained within the field file, as opposed to changing the way validation is done in flexinode.module for example. All told though, I thought it was the right thing to do.
The above required a quick change to ..._format() as well.
This patch also gets rid fo a spurious 'eh?' that got into the code somehow (#57559).
Comment #2
Bèr Kessels commentedLooks good to me,using the hidden is indeed not perfect, but far better then rewriting a part of the validation system.
I need one reviewer though, to confirm that this does not open any new bugs.
Comment #3
samc commentedThis patch probably not needed pending proposed changes in #59733
Will update status here pending implementation and testing.
Comment #4
samc commentedTurns out the field's form still needs to be patched, because flexinode_content() also checks for $node->$fieldname. However, rather than using a hidden form field, I used the #value "special element", which isn't sent to the browser.
In order to ensure preview works correctly, the ..._timestamp_format() function was updated:
Comment #5
samc commentedWhile the patch supplied in #4 above fixes the original issue allowing require date fields to pass validation, the validation provided for date fields is still poor.
I also created a patch, supplied in issue 60030, that adds more rubust validation to the date fields.
Comment #6
samc commentedI'm proposing to mark this issue closed.
Based on the fix in #59733, required date fields are validating properly.
There are still issues with date fields properly displaying when during preview, but I will open a new issue for that.
Comment #7
(not verified) commented