Trying to integrate Zurb foundation validation into an umbraco MVC implementation and need to add a custom attribute to the MVC form while using BeginUmbracoForm.
After using the Umbraco.tv Surface Controllers/Handling Posts tutorial and Dirk's answer above, I still can't fathom out the syntax for adding the html attributes role="form" id="bookingForm" to this:-
Thanks for that. It worked perfectly and helped me understand the syntax.
The issue I have with the documentation is that without real-world examples I can't make head nor tail of them. Same with Microsoft's docs. They're ok as a reference (i.e. if you already know it but have just forgotten) but useless for learning. For instance they don't tell you what the HTML output will be, which is the whole point of doing it in the first place;)
i'm finding this information very helpful. However I have a unique situation with the HTML that I have in my form that I am bringing into Umbraco/Partial View:
There are two issues:
1) <input type="email" required>
Is this bad HTML?? Because I cannot render out just the "required" element for the input tag because I have to add a object which wants the key|value pair. The only way I can do it is to add the object:
new { @input = "required" }
...but the render result is
Update! ...I'm still having problems with adding the span tags in the label to color the * however I have found a sort of workaround for the 1st issue - the required element of the input tag:
@Html.TextBoxFor(m => m.Name, new { @required = "" })
Adding custom attribute to BeginUmbracoForm
Hi
Trying to integrate Zurb foundation validation into an umbraco MVC implementation and need to add a custom attribute to the MVC form while using BeginUmbracoForm.
Anyone know of a way of doing this?
Jules
Here you go:
@using (Html.BeginUmbracoForm("Action", "Surface", null, new Dictionary<string, object> { { "attribute", "attribute-value" } }))
/Dirk
Marvellous. Works perfectly
Cheers
Jules
Hi,
After using the Umbraco.tv Surface Controllers/Handling Posts tutorial and Dirk's answer above, I still can't fathom out the syntax for adding the html attributes role="form" id="bookingForm" to this:-
so the final HTML output would be this:-
Any clarity appreciated :)
Add to the top of your view the following line
Then change "Action" to "HandleFormSubmit" and "Surface" to "bookingFormSurface" in dirks example above to route the form to your controller.
finally your dictionary object would be.
This should work, there are in fact many overloads to the BeginUmbracoForm method which can be found in the documentation here:
Mvc Forms documentation
Thanks for that. It worked perfectly and helped me understand the syntax.
The issue I have with the documentation is that without real-world examples I can't make head nor tail of them. Same with Microsoft's docs. They're ok as a reference (i.e. if you already know it but have just forgotten) but useless for learning. For instance they don't tell you what the HTML output will be, which is the whole point of doing it in the first place;)
hello!
i'm finding this information very helpful. However I have a unique situation with the HTML that I have in my form that I am bringing into Umbraco/Partial View:
There are two issues:
1)
<input type="email" required>
Is this bad HTML?? Because I cannot render out just the "required" element for the input tag because I have to add a object which wants the key|value pair. The only way I can do it is to add the object:
new { @input = "required" }
...but the render result is
The second issue I'm having with using the Html helper methods is to try and render this:
I'm currently using it this way, which alwmost works:
The result of this is close:
...my problem is that I cannot use the span tag with the "start" class attribute.
Any ideas? If this is not way to do this then fine; I just want to be sure there isn't some way of doing this to match the markup that I received.
Thanks very much for any assistance. Daniel
Update! ...I'm still having problems with adding the span tags in the label to color the * however I have found a sort of workaround for the 1st issue - the required element of the input tag:
Which comes out looking like this:
...and it works. The jquery is still able to pick up the field and is doing the client side validation.
Hope this may be of help to anyone else who hit this problem.
I'm trying to reload my form with an anchor in the url
topic-address-finderare-you-taking-part-in-the-trial"
is working on a reply...