Closed (fixed)
Project:
Taarikh
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Dec 2017 at 09:05 UTC
Updated:
17 Jan 2018 at 08:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
anas_maw commentedInitial date for date conversion, still need much improvements.
Please review and give me any comments to work on.
Comment #3
hussainwebThanks for creating this issue.
I am largely torn between two methods of conversion right now. As you might have seen, there are two things responsible for rendering the popup picker–the field widget, and the form element under it. I am wondering where I should actually convert the dates.
It's easy to convert the dates in the widget, but a side effect of that is that the form element would only return dates in another calendar, never a date you can actually use for storage (maybe that's a good thing). Alternatively, we can handle the conversion in the TaarikhDate element itself, which is slightly tricky as I am not very sure how to cleanly access the taarikh plugin manager from there.
Comment #4
anas_maw commentedI think converting the date should be on form element, in this case if someone create a custom widget and use our taarikh form element he will get everything working fine.
(note: the last patch work on taarikh_date form element, we should fix taarikh_datetime from element also)
Comment #5
hussainwebThat makes sense. I suppose it is reasonable for it to work this way as long as it is documented properly.
Speaking of which, there is another point to decide. There are variations in different calendar systems–even in hijri (right now, I have only implemented one). I am thinking of how that choice should be exposed to the site builders. Should this be a site-wide setting or should the site builder be able to specify the calendar system per widget and formatter. Thoughts?
Comment #6
anas_maw commentedMaking this site wide much easier. but adding the option on widget and formatter will make the module much better than others trying to do the same functionality.
Comment #7
anas_maw commentedUpdated patch
Note: this patch should be ported to TaarikhDatetime form element
Comment #8
hussainwebCreated #2933763: Taarikh Date Object.
Comment #9
hussainweb@Anas_maw, thanks for the patch. My primary concern with them is how the algorithm service instances were created. I have been working on a similar methodology and it is close to working. Here is the patch so far.
Comment #10
hussainwebIt works for regular node save and load but fails when there is a validation error in some other field and the node edit form is shown again. I suspect this happens because valueCallback is not called again (as #value would already be set). As such, I don't like the method of unsetting #value we are doing here.
I don't see a way around this for now. One thought is that I move the conversion logic to processDate and validateDate methods instead of keeping it entirely in valueCallback. I am going to try this now.
Comment #11
anas_maw commented@hussainweb yes i had this issue and i solved it with a dirty work around, solving this will be great.
Thanks,
Comment #12
hussainweb@Anas_maw, can you share your workaround? FYI, moving the logic out of valueCallback results in a slightly similar problem.
Comment #13
anas_maw commentedI did a date re conversion if there is any form validation error throw adding a custom function in form_alter
Dirty temporary fix :)
Can we have this fixed if we do the conversion in widget instead of form element?
Comment #14
hussainwebThis works. I tested all scenarios I can think of and it worked fine. Reviews appreciated.
Comment #15
hussainwebI am calling it a day. I'll test this again tomorrow and after some clean-up and resolving review comments, if any, I will commit this. Thanks for all your help.
Comment #16
anas_maw commentedSeems like the last patch working fine.
Comment #18
hussainwebThanks for testing and reviewing. I did some cleanup and pushed the changes.