Kentico Forms Default Value Macro for Date Time Field

Daniel Kasmar asked on April 23, 2019 17:36

I am attempting to create a form for a user to checkout an item that will later need to be returned (in this case 48 hours after checkout). I have two date time picker fields EquipmentCheckout and EquipmentCheckin. The first field the user selects, causing the dependent field EquipmentCheckin to appear. I would like EquipmentCheckin to have its default value be the value of EquipmentCheckout + 48 hours. Right now though, I am struggling to even pull the value of EquipmentCheckout at all, let alone manipulating it.

My first thought was to pull the data from the EquipmentCheckout field in the same way that I had been checking the values for the purposes of displaying dependent fields. Thus I came to {% EquipmentCheckout.Value #%}. However, this and a slew of other variations of syntax returned a blank field for EquipmentCheckin. I have also attempted using the ToString() and ToDateTime() methods thinking that maybe the data had been improperly formatted, but to no avail. I have also tried any number of combinations using the GetValue() method in place of Value with similar results. I have also looked at using CurrentDocument but am unsure what syntax I should be using.

Does anyone have a suggestion/example of what I should be doing?

Thanks

Update:

It seems I simply cannot change the text of a date time picker in this method. I have succeeded in getting text to show up in a text box, but am still unable to pull the value of EquipmentCheckout. My latest macro is {% ToDateTime(EquipmentCheckout.Value).AddHours(48) #%} which results in 1/3/0001 12:00:00 AM.

   Please, sign in to be able to submit a new answer.