Developer forum

Forum » Templates » How to include hidden fields in e-mail template?

How to include hidden fields in e-mail template?

Ton Martens
Reply

Hi,

Using datamanagement-forms, I made forms which contain hidden fields. The value of this field is filled by Javascript. The value gets nicely into the table, but the e-mail doesn't contain hidden fields. The template for e-mail is indicated at the paragraph module (email_form).

How can I get the template to include hidden fields?

Thanks,

Ton

 

 

 

 


Replies

 
Mikkel Ricky
Reply

Hidden fields are handled in a special way by the Data Lists Form module: They are not rendered inside the Form.Fields loop, but are rendered together with other hidden system fields in the @Form.Hidden template tag. The reason for this is that they should not affect the layout of the form, e.g. by rendering empty table rows (when using the default templates).

Right now, the best solution to this challenge is to change the hidden field to regular text fields and modify the form template to make them hidden:

<div>
	<!-- Render "visible" fields -->
	<!--@LoopStart(Form.Fields)-->
	<!--@If Not(Field.Label<contains>_hidden)-->
	<!--@Field.Label-->: <!--@Field.Control-->
	<!--@EndIf-->
	<!--@LoopEnd(Form.Fields)-->
</div>

<!-- Render "hidden" fields -->
<div style="display: none">
	<!--@LoopStart(Form.Fields)-->
	<!--@If(Field.Label<contains>_hidden)-->
	<!--@Field.Control-->
	<!--@EndIf-->
	<!--@LoopEnd(Form.Fields)-->
</div>

It's not a very good solution, but it works.

Another way to do it, is to use the notifications Notifications.Form.OnBeforeRender and Notifications.Form.OnAfterRender to render the hidden fields, but this requires custom code.

I've created a backlog item for this issue and we'll see if it makes sense to handle hidden fields just like non-hidden field in the form.

Best regards,
Mikkel

 

 

 

 

 

 
Nuno Aguiar
Reply

Hi Mikkel,

 

If you can, drop a eye on http://developer.dynamicweb-cms.com/forum/feature-requests/data-management-form-date-and-time.aspx and http://developer.dynamicweb-cms.com/forum/feature-requests/data-management-form-features.aspx

 

I believe this module could really use some minor tweeks to enhance usability

 
Ton Martens
Reply

Thanks Mikkel!

 
Rob Lohmann
Reply

Any news regarding this? We're running into the same issue over here, so this functionality is much appreciated!

 

You must be logged in to post in the forum