Does a RadzenTemplateForm must have a Data parameter?

So once more I've hit the "Form won't submit" stumbling block, and each time I fiddle on and fiddle on, eventually I get it to work, but it seems very un-reliable.

This time, keeping track of what I'm doing, it seems to be the "Data" attribute that's the problem.

Form template declaration looks like this:

Handlers are set up like this:

And the submit button inside the form tag like this:

No matter how many times I hit the submit button neither the good or the bad submit handlers get hit, I've also tried various combinations of @ symbols on variable names, attribute names and nothing seems to work.

I have another form set up the exact same way, accept all of it's data is in one object, and that object is set as the "Data" parameter, I have no problems with that.

In the case of this dialog however, I cannot give it a single object, as the input data is made up from a number of different data sources, read from individual drop downs and such like on the form, and then combined into a single object in the submission handler before being sent to the database.

I want to use the TemplateForm, so that I can attach validators to some of the form fields, which I don't believe I can use without a templateform, but how am I supposed to use the template form if I must give it a single data object in it's data attribute, it makes no sense?

Currently the RadzenTemplateForm fires the Submit event only when the Data property is set. You can check the implementation here: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenTemplateForm.cs

The Data property is needed to create the Blazor EditContext object which is required for validation.

Hi Korchev,

Thanks for confirming that. will there ever be a time when this is not the case?

For now, I've found if I create an empty object in my dialog, and assign that, it works, but it seems a bit of a waste.

Thanks
Shawty

I don't think so as validation will not work without the Data property. Validation is one of the only reasons to use the RadzenTemplateForm to begin with. If you don't need it you can just use the components without a form and handle the Click event of the submit button.

Yes, I agree I could, but using the validation components is just so easy, there's almost no boiler plate code needed, drop a couple of tags on, link them and job done.

To handle using a submit requires lot's and lots of boring if this, then that, otherwise this.

In many cases a very common use case (Is similar to mine) where raw data that doesn't conform to any specific shape of record is to be entered, and then when all the inputs from multiple sources are validated, then everything is wrapped up and packaged to be processed.

Think "sales order" plus "list of additional sales items", but these parameters are defined elsewhere, and then saved in some kind of global state, then combined, with existing database data (Addresses, contact people, shipping carriers etc), into one big "order" to be processed.

This final form for example, might only be used to confirm things like shipping addresses and such like, so all that needs to be validated is maybe a order number, a couple of drop downs and some emails.

It's great to just drop 4 validators into the form, hook them up, rather than having to beat out 10/15 lines of boiler plate code to validate each simple field.

It would be very nice if there was a way to use the validators outside the template form in some way.

Thanks again though, a dummy object solves things for now.

As far as we know Blazor validation is model based and thus the RadzenTemplateForm needs the Data property to be set to some value.