How to display hidden input value in email template
I have seen a few threads about how to include the page name in the email template, but none seem to give a full solution. I am using javascript to populate a hidden input with the page name, but I'm not sure how to display this hidden input value in the email template partial view? This hidden input isn't being added via the Form builder fields, I have hard coded it in in the 'Render.cshtml' file, eg...
This hidden input isn't being added via the Form builder fields
Why not? I expect that'd solve your issue.
Personally, I'd create a new field type, then in the CSHTML file for that field, output a hidden field that contains the page name. No need for any JavaScript.
The content and forms are being managed by one of my clients, and it's a bit clunky to ask them to remember to add a custom hidden field every time they create a new form. They are going to have lots of different forms and CTA's on many different pages throughout the site - was just wondering if it could be done programmatically without relying on the CMS user to add the extra hidden field.
But thanks for your suggestion of creating a new field type, that will work if there is no other solution.
But thanks for your suggestion of creating a new field type, that will work if there is no other solution.
You might be able to use the API to automatically add the field to the form when the form is first created. If not, I think forms are stored as JSON in the latest versions of Umbraco Forms, so you could programmatically modify those JSON files if necessary. A bit hacky, but if you really want to automate it then that may be a viable option.
Another option would be for you to modify the Form.cshtml file that handles the rendering of the form. At least, I think that's the file (it was back when Umbraco Forms was still known as Contour). If the form doesn't contain the custom field, you can instead render a message that says "looks like you forgot to add such and such a field, here's how you do it." That way, at least the person creating the form can be notified when they forgot something.
How to display hidden input value in email template
I have seen a few threads about how to include the page name in the email template, but none seem to give a full solution. I am using javascript to populate a hidden input with the page name, but I'm not sure how to display this hidden input value in the email template partial view? This hidden input isn't being added via the Form builder fields, I have hard coded it in in the 'Render.cshtml' file, eg...
And in the header I have a meta tag for the page name...
And then I use js to populate the hidden field...
Has anybody got information about how to display this hidden input value in the email template partial view?
Why not? I expect that'd solve your issue.
Personally, I'd create a new field type, then in the CSHTML file for that field, output a hidden field that contains the page name. No need for any JavaScript.
The content and forms are being managed by one of my clients, and it's a bit clunky to ask them to remember to add a custom hidden field every time they create a new form. They are going to have lots of different forms and CTA's on many different pages throughout the site - was just wondering if it could be done programmatically without relying on the CMS user to add the extra hidden field.
But thanks for your suggestion of creating a new field type, that will work if there is no other solution.
For things that are harder to remember, it can be useful to add a dashboard to the Umbraco Forms section with instructions (scroll down to "Add a Custom Dashboard"): https://code101.net/clean-up-your-umbraco-dashboards-f42b256d539d
You might be able to use the API to automatically add the field to the form when the form is first created. If not, I think forms are stored as JSON in the latest versions of Umbraco Forms, so you could programmatically modify those JSON files if necessary. A bit hacky, but if you really want to automate it then that may be a viable option.
Another option would be for you to modify the
Form.cshtml
file that handles the rendering of the form. At least, I think that's the file (it was back when Umbraco Forms was still known as Contour). If the form doesn't contain the custom field, you can instead render a message that says "looks like you forgot to add such and such a field, here's how you do it." That way, at least the person creating the form can be notified when they forgot something.is working on a reply...