If anyone comes here i made a custom datatype for the solution.
In app folder: Add a new class HiddenFieldPageId.cs and add this
Add this (Important the "this.Name" must be the name of the file ~/Views/Partials/Forms/Themes/default/Fieldtypes/FieldType.HiddenFieldPageId.cshtml, without "Fieldtype." )
public class HiddenFieldPageId : FieldType
{
public HiddenFieldPageId()
{
//Provider
this.Id = new Guid("d6a2c406-cf89-11de-b075-55b055d89593");
this.Name = "HiddenFieldPageId";
this.Description = "Renders a hiddenfield With value of currentpageid";
this.Icon = "icon-autofill";
this.DataType = FieldDataType.String;
this.SortOrder = 10;
}
}
In the folder Views\Partials\Forms\Themes\default\Fieldtypes\ copy the Fieldtype.Hiddenfield and rename to FieldType.HiddenFieldPageId.cshtml and paste the code below.
@model Umbraco.Forms.Mvc.Models.FieldViewModel @{
var umbraco = new UmbracoHelper(UmbracoContext.Current);
var currentPage = umbraco.TypedContent(UmbracoContext.Current.PageId);}
Add the code to the Views\Partials\Forms\Emails\Example-template.cshtml
var pageId = Model.DynamicFields.pageId;
var pageUrl = siteDomain + Umbraco.TypedContent(pageId).Url;
var pageName = Umbraco.TypedContent(pageId).Name;
Now you have access to the pagename and url via the id.
Build the solution and add the new formfield to the form
Umbraco form 6.0.5 - Hiddenfield error Page id
Hi
Current installed version of Umbraco Forms: "6.0.5" Umbraco version 7.7.6
I have this strange error on Umbraco forms
I have to get the page id and send with the form.
When i have the page id i can get the url of the page and the pagename.
For testing i have added the page id as a short answer.
(I have it in a hidden field in production)
But when i post the form i get a different url.
The page id is different from the value posted by the form.
The correct id is 8083.
René
Hi
I have been looking closer in to this.
It is the value on the hidden field, it shows the previous page i had visited.
René
Hi
Some more information.
Now i have tried to wait some time.
The first time i submit the form it is correct.
The second time i get the previous ID send.
If i change the browser and submit the form i get the wrong ID.
It seems for me it is some cache in Umbraco Form. Any ideas would be great..
Thanks in advance.
René
Hi Umbraco form team
Is there any one :-)
René :)
HI
If anyone comes here i made a custom datatype for the solution.
In app folder: Add a new class
HiddenFieldPageId.cs
and add this Add this (Important the "this.Name" must be the name of the file ~/Views/Partials/Forms/Themes/default/Fieldtypes/FieldType.HiddenFieldPageId.cshtml, without "Fieldtype." )In the folder
Views\Partials\Forms\Themes\default\Fieldtypes\
copy the Fieldtype.Hiddenfield and rename toFieldType.HiddenFieldPageId.cshtml
and paste the code below.Add the code to the
Views\Partials\Forms\Emails\Example-template.cshtml
Now you have access to the pagename and url via the id.
Build the solution and add the new formfield to the form
is working on a reply...