0

Has anyone able to set the current date in Sitecore form 10.1 date picker?

Just like WFFM, we used the following script to set the current date.

@Html.RenderScriptBlock(
    @<script type="text/javascript">
         if (typeof window.WffmFieldsData === 'undefined') {
             window.WffmFieldsData = {}
         }

         window.WffmFieldsData["@Html.IdFor(x => Model.Value)"] =
         {
             'defaultDate': new Date('@Model.Value'),
             'dateFormat': '@ClientDateFormatConverter.ConvertToClientFormat(Model.DateFormat)',
             'minDate': new Date('@Model.StartDate.Year', '@(Model.StartDate.Month - 1)', '@Model.StartDate.Day'),
             'maxDate': new Date('@Model.EndDate.Year', '@(Model.EndDate.Month - 1)', '@Model.EndDate.Day'),
         };
     </script>
)

I want to do the same in Sitecore forms date picker.

Any suggestions would be appreciated.

Thanks in advance

1 Answer 1

0

If you want to set the default value in Sitecore Form controls for example a dropdown or a date picker then you need to implement a custom Form Value Provider.

You can follow this article to know how to implement a Value provide for prefilling form.

https://doc.sitecore.com/xp/en/developers/91/sitecore-experience-manager/walkthrough--setting-up-a-value-provider-for-prefilling-forms.html

I have also given the answer to the same kind of scenario but that is for the drop-down list. Here is the link.

Setup value provider for dropdown list field in Sitecore forms using IFieldValueProvider

Hope this will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.