This project is read-only.

Custom Forms prepopulate some fields

Topics: Nederlands (Dutch), Writing modules
Feb 10, 2015 at 8:02 PM

I have created a custom form that handles reservations for a website I'm building. The problem is that the reservation date is chosen from another page (in a widget) before filling in the actual reservation form (custom form).

What would be the best way to get the selected date (from my widget on other page) in the reservation form (custom form)?

Areas I have looked into are:
  1. Use the ContentPartDriver's Editor method of the Custom Form and in that method access the workercontext to extract the values from the query string
  2. Extract the parameters as query string parameters in javascript/razor
  3. Check how the Pager is doing it. But that all works from ViewModels and my custom form isn't called from a ViewModel.
If anyone could point me in the right direction that would be very welcome. Options 1 and 2 might work but I dislike doing it that way.
Feb 11, 2015 at 7:42 AM
In your theme, you could make an alternate view of the fields you want to populate and then check the querystring parameter.
Feb 11, 2015 at 7:52 AM
You mean via .DisplayFor / .EditorFor? Interessting to try that one out. But via the querystring would be the way to pass the data to my custom form?
Feb 11, 2015 at 9:15 AM
Yes, you can override the EditorTemplates\Fields\YourField.Edit.cshtml copying it in your theme.