Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Date / Time Field shows Date only in Read-Only mode on Edit Form (non en-us sites) #68
The Dom Model for the value is
Also tried to switch between "Friendly" and "normal" display within the field settings. Didn't make a difference and I kept the normal version.
My environment for this application is SP Online within O365.
I haven't seen this before. In general, SPEasyForms does not pull any data from the server. When you mark a field read only, it just pulls the value from the editable field, inserts it as a read only value, and then and then hides the editable field. So if the field is a datetime and the time is there, it will show the time, if it's not it will not.
When you say you marked the fields read-only in the edit form, did you do that in SPEasyForms?
The Dispform does show Date & Time correctly, with the same configuration.
If I switch the rule from "Read-Only" to e.g. "Highlight in Red" it also works in edit form, and the Time controls show up.
I wonder, when transformation starts, what fields are selected as there are 4 tds: First for the date, Second for the Calendar picker control, third for hour input implemented as selction, fourth for minutes input also as selection.
Hope this additional info helps!
I cannot reproduce this on my O365 tenant, but now that I've seen your screenshot it is clearly a language/culture specific issue. Can you send me the DOM for the TD containing the original DateTime field, so I can compare with what I'm seeing.
To get the time, I'm querying the row for select elements like:
var selects = tr.row.find("select");
and expecting there to be exactly 2 of them. The value of the first one I expect to be the hour in the format "1 AM", so I further parse this to get the hour and the AM/PM (clearly herein lies the problem). If any of this doesn't work I skip the time because I don't know how to parse it.
None of this is ideal. Ideally I'd use some third part tool like moment.js to deal with DateTime localization, but the problem here is one that moment.js won't help with. So on my en-us tenant, I have 3 controls with values:
And I need to turn these 3 values into a useful date before I can even pass it to something like moment.js. I can't just concat them for instance, since '8/31/2017 1 AM 30' is not a valid date time. So I have to parse the second value in order to get useful information out of the date. In your case you have:
And I fail to parse the hours because there is no space followed by AM/PM (which makes sense because I assume your localized time uses 24 hour notation), so I skip the time. I don't want to risk crashing the page by trying to parse something I clearly don't understand, and I have no idea how many variations there might be throughout the SharePoint-using world. The controls here are localized, but in a Microsoft-specific way; no third part date library is going to understand those controls.
It should be easy enough for me to fix. In order to fix it, I need to confirm that the DOM is the same in your localized time (it probably is), and I need to know what '1:30 AM' and '1:30 PM' look like in your localized time; I assume that's '1:30' or '13:30'? The simplest solution would be if I don't see AM or PM to assume 24 hour notation. That would fix it for most of Europe and I'm sure a bunch of other countries as well.
And here is our Datepicker in an editform, before SPEasyForms-Magic starts:
Please note: You might notice some "Disabled" properties, that you can ignore. They get inserted by some jquery to workaround my current issue.