Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Date Time Picker Validation View modes: 
User avatar
Member
Member
@davey_lad - 4/23/2013 5:16:09 AM
   
Date Time Picker Validation
This is a general question related to the Date/Time picker form controls but it came to light when I've been working with the Booking Events module.

When you have a pair of date time pickers on your form which are used to control a range, in this case "Open From" and "Open To" it is possible to set the "To" date to a value which is before the "From" date. Clearly this is a stupid thing to do, but Kentico doesn't flag up any warnings of this and it seems that you can't set any validation rules to prevent it happening.

This is also possible when using the Publish From/To option on a document. I can't believe I'm the only one to notice this .. would anyone care to share their workarounds or solutions.. or even point out that I'm completely wrong and tell me how ?

I don't mind being told I'm wrong.. honest.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 4/23/2013 8:53:30 AM
   
RE:Date Time Picker Validation
The publish to/from dates has been like this since, well probably forever. I've only been able to do validation like you are talking about in my custom webparts using the control and having to specifically code it. I haven't been able to do it at all in a form using the UI. If you're creating your own webpart, then I'd suggest validating on your own, if not, you could write a global handler to do the checking.

On another note, I've also noticed the IsValidRange() doesn't work as I expected it to. Same with UseCalendarLimit. Maybe I'm just not understanding what the methods and properties are supposed to do but they seem like they are easy enough to figure out.

User avatar
Member
Member
@davey_lad - 4/23/2013 9:07:14 AM
   
RE:Date Time Picker Validation
Thanks for the reply,

Unfortunately in this case I don't have the luxury of time to develop my own Form Control for this, timescale is very aggressive on this project and I'm trying to keep things as "out of the box" as I can.

Hooking in to the global events may be an option but I haven't quite figured out how you "cancel" the save/update operation. Also, how would you go about displaying a meaningful message to the editor in the same way as a regular validation error ?

I'm fast learning that out of the box is rarely good enough in the real world when it comes to Kentico sites however. The majority of solutions on these forums tend to end along the lines of "just develop your own". I don't think I've used a feature yet that I haven't had to customise in some way to meet a client's specific requirements. The alternative is to reign in the client's requirements and expectations. This seems like just another case.

:/


User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/23/2013 6:27:47 PM
   
RE:Date Time Picker Validation
Hi,

The fields are two separate fields right now - in both cases you have mentioned you can use them to schedule - in the publish from/to fields you can schedule the publishing of the document. If you are not using workflow and you do not want to publish the document yet, you will set the TO field into the past or the FROM field into far future. The same idea applies for the booking events - if you want to keep it closed for a while, you can set the TO value into the past.

I understand the customizations - Kentico is a general product and it is hard to fit every customer's needs. However, you can use our UserVoice portal for adding new requirements and if there are more customers asking for it - it will be done.

Best regards,
Juraj Ondrus