Developer forum

Forum » Templates » Custom user form is not saving data

Custom user form is not saving data

Jose Caudevilla
Reply

Hi:

I have to create a user form (like set user address data) with custom data. I need that the user can set this data using the front-end.

The problem is that i created this custom formular, when i set data to this formular and submit it the data is not saved.

 

This is the stepts that i followed. First i created the itemType:

 

Next, i asociated this itemType to a user group:

Then i create the formular app:

 

And this is the formular template:

@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
@using Dynamicweb.Rapido.Blocks
@using Dynamicweb.Rapido.Blocks.Components.General
@using System.Web

@functions {
    BlocksPage defaultFormPage = BlocksPage.GetBlockPage("FormPage");
}

@{
    Block formPlaceholder = new Block
    {
        Id = "Form",
        SortId = 10,
		Template = RenderPercentajesForm(),
    };

    defaultFormPage.Add(formPlaceholder);
}


@helper RenderPercentajesForm()
{
	@RenderHeading(new Heading { Title = Translate("Porcentajes"), Level = 2 });
	
	@GetString("Form.Start");

	@GetString("Form.Hidden");
			
	
	foreach (LoopItem item in GetLoop("Form.Fields")) {
        <label for="@item.GetString("Field.Systemname")">@item.GetString("Field.Name")</label>
		<input type="text" id="@item.GetString("Field.Systemname")" name="@item.GetString("Field.Systemname")" value="@item.GetString("Field.Value")"/> 
     
    }
          
                  
    @GetString("Form.Button.Submit");


	@GetString("Form.End");



}

@Include("../Blocks/Form.cshtml")
@Include("../Blocks/Custom__Blocks.cshtml")

@* Include the Rendering helpers *@
@Include("../Components/GridBuilder.cshtml")
@Include("../Components/GeneralComponents.cshtml")



@* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
@RenderBlockList(defaultFormPage.BlocksRoot.BlocksList)

 

I think the problem is there something wrong in my template.

 

Regards,

Jose.


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

What comes out if you add @TemplateTags() right after this line:

@GetString("Form.Hidden");
 
Jose Caudevilla
Reply

 

Hi Nicolai:

 

This is the output of the templateTags():

 

 

 

Form.Button.Reset System.String <input type="reset" />
Form.Button.Submit System.String <input type="submit" value="Guardar" />
Form.End System.String </form>
Form.Fields.ABATIDOR_DE_TEMPERATURA.Active System.String True
Form.Fields.ABATIDOR_DE_TEMPERATURA.Control System.String <input type="text" id="ABATIDOR_DE_TEMPERATURA" name="ABATIDOR_DE_TEMPERATURA" value="" />
Form.Fields.ABATIDOR_DE_TEMPERATURA.DefaultValue System.String  
Form.Fields.ABATIDOR_DE_TEMPERATURA.Description System.String  
Form.Fields.ABATIDOR_DE_TEMPERATURA.Heigth System.Int32 0
Form.Fields.ABATIDOR_DE_TEMPERATURA.Label System.String ABATIDOR_DE_TEMPERATURA
Form.Fields.ABATIDOR_DE_TEMPERATURA.MaxLength System.String  
Form.Fields.ABATIDOR_DE_TEMPERATURA.Name System.String ABATIDOR_DE_TEMPERATURA
Form.Fields.ABATIDOR_DE_TEMPERATURA.Required System.String True
Form.Fields.ABATIDOR_DE_TEMPERATURA.Systemname System.String ABATIDOR_DE_TEMPERATURA
Form.Fields.ABATIDOR_DE_TEMPERATURA.Type System.String TextInput
Form.Fields.ABATIDOR_DE_TEMPERATURA.Type.TextInput System.Int32 1
Form.Fields.ABATIDOR_DE_TEMPERATURA.ValidationValue System.String  
Form.Fields.ABATIDOR_DE_TEMPERATURA.Value System.String  
Form.Fields.ABATIDOR_DE_TEMPERATURA.Width System.Int32 0
Form.Fields.ACCESORIOS_GAMA_BLANCA.Active System.String True
Form.Fields.ACCESORIOS_GAMA_BLANCA.Control System.String <input type="text" id="ACCESORIOS_GAMA_BLANCA" name="ACCESORIOS_GAMA_BLANCA" value="" />
Form.Fields.ACCESORIOS_GAMA_BLANCA.DefaultValue System.String  
Form.Fields.ACCESORIOS_GAMA_BLANCA.Description System.String  
Form.Fields.ACCESORIOS_GAMA_BLANCA.Heigth System.Int32 0
Form.Fields.ACCESORIOS_GAMA_BLANCA.Label System.String ACCESORIOS_GAMA_BLANCA
Form.Fields.ACCESORIOS_GAMA_BLANCA.MaxLength System.String  
Form.Fields.ACCESORIOS_GAMA_BLANCA.Name System.String ACCESORIOS_GAMA_BLANCA
Form.Fields.ACCESORIOS_GAMA_BLANCA.Required System.String True
Form.Fields.ACCESORIOS_GAMA_BLANCA.Systemname System.String ACCESORIOS_GAMA_BLANCA
Form.Fields.ACCESORIOS_GAMA_BLANCA.Type System.String TextInput
Form.Fields.ACCESORIOS_GAMA_BLANCA.Type.TextInput System.Int32 1
Form.Fields.ACCESORIOS_GAMA_BLANCA.ValidationValue System.String  
Form.Fields.ACCESORIOS_GAMA_BLANCA.Value System.String  
Form.Fields.ACCESORIOS_GAMA_BLANCA.Width System.Int32 0
Form.Fields.PORCENTAJE_POR_DEFECTO.Active System.String True
Form.Fields.PORCENTAJE_POR_DEFECTO.Control System.String <input type="text" id="PORCENTAJE_POR_DEFECTO" name="PORCENTAJE_POR_DEFECTO" value="" />
Form.Fields.PORCENTAJE_POR_DEFECTO.DefaultValue System.String  
Form.Fields.PORCENTAJE_POR_DEFECTO.Description System.String  
Form.Fields.PORCENTAJE_POR_DEFECTO.Heigth System.Int32 0
Form.Fields.PORCENTAJE_POR_DEFECTO.Label System.String PORCENTAJE_POR_DEFECTO
Form.Fields.PORCENTAJE_POR_DEFECTO.MaxLength System.String  
Form.Fields.PORCENTAJE_POR_DEFECTO.Name System.String PORCENTAJE_POR_DEFECTO
Form.Fields.PORCENTAJE_POR_DEFECTO.Required System.String True
Form.Fields.PORCENTAJE_POR_DEFECTO.Systemname System.String PORCENTAJE_POR_DEFECTO
Form.Fields.PORCENTAJE_POR_DEFECTO.Type System.String TextInput
Form.Fields.PORCENTAJE_POR_DEFECTO.Type.TextInput System.Int32 1
Form.Fields.PORCENTAJE_POR_DEFECTO.ValidationValue System.String  
Form.Fields.PORCENTAJE_POR_DEFECTO.Value System.String  
Form.Fields.PORCENTAJE_POR_DEFECTO.Width System.Int32 0
Form.Hidden System.String <input type="hidden" name="ID" value="3482" /><input type="hidden" name="FormPID" value="3888" /><input type="hidden" name="FormID" value="3" /><input type="hidden" name="SubmitForm" value="true" /><style>.dw89a684a4f296401f3e854d644fa5f5edmaps{display:none!important}</style> <input type="hidden" name="_sys_to_email" value="mrsmith@dynamicweb.com" /> <input type="hidden" name="FormCH1_h" value="" /> <input type="hidden" name="FormCH1_f" value="1e9ae4c6d0a4e03e63c9d7b5363266ec" /> <input type="hidden" name="FormCH1_s" value="cf7ae65758f693f862fe2c40560207e4" /> <input type="hidden" name="FormCH1_i" value="65957e18bdcfd6fc4556e2d70b50a0fd" /> <input type="hidden" name="89a684a4f296401f3e854d644fa5f5edts" value="tHfIwEtwMb9ojpjVRknytqREDKcEti8Y" class="dw89a684a4f296401f3e854d644fa5f5edmaps" /> <input type="text" name="89a684a4f296401f3e854d644fa5f5eddescription" value="" class="dw89a684a4f296401f3e854d644fa5f5edmaps" /> <input type="text" name="89a684a4f296401f3e854d644fa5f5edemail" value="mrssmith@dynamicweb.com" class="dw89a684a4f296401f3e854d644fa5f5edmaps" />
Form.ID System.Int32 3
Form.Name System.String Porcentajes usuario
Form.OnSubmit System.String s=function(e){e.elements['FormCH1_h'].value='89a684a4f296401f3e854d644fa5f5ed';e.elements['_sys_to_email'].value='';e.setAttribute('action', 'http://XXXXXXX/Default.aspx?ID=3482');return true};return s(this);
Form.SpamScript System.String s=function(e){e.elements['FormCH1_h'].value='89a684a4f296401f3e854d644fa5f5ed';e.elements['_sys_to_email'].value='';e.setAttribute('action', 'http://XXXXXX.com/Default.aspx?ID=3482');return true}
Form.Start System.String <form method="post" id="FormSave3" name="FormSave3" enctype="multipart/form-data" action="/Admin/Public/404.aspx" onsubmit="s=function(e){e.elements['FormCH1_h'].value='89a684a4f296401f3e854d644fa5f5ed';e.elements['_sys_to_email'].value='';e.setAttribute('action', 'http://XXXXX.com/Default.aspx?ID=3482');return true};return s(this);">
Template:BaseUrl System.String /Files/Templates/DataManagement/Forms/Form/
Template:DesignBaseUrl System.String /Files/Templates/Designs/Rapido/
Loops  
Form.Fields  

FieldOptions

Regards ,

Jose. 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Well, now I saw what you are doing. (Please do not attach Spanish screendumps as I cannot read it :-))

You have an item that you add on a user. And tries to use forms for datalist to do something with it...? How are these things related...?

I think you need to ensure you create the right form template to save records to the forms for datalists form. I cannot help you with that.

BR Nicolai

 

You must be logged in to post in the forum