Developer forum

Forum » Templates » Forms for editors - not active fields is still outputted in receipt

Forms for editors - not active fields is still outputted in receipt

Lise T. Pedersen
Reply

In forms for editors I have a form which is used for subscription for some meetings, one each month over the year. And when the meetings is over, we are deactivating the checkbox field for this. (We use the same form every year, therefore it's a kind of "reuse" that we are not deleting them instead)

But they are still outputted in the mail and receipt - can I in some way write in the cshtml-template, that only active fields must be outputted?

Thanks

Lise


Replies

 
Nicolai Pedersen
Reply

Hi Lise

I can see that. I've created a bug and a bugfix alread, TFS#39233

It seems that you cannot fix it in the template because of the lacking .Active template tag.

You can however, since it is a Razor template, do something like this:

if(Dynamicweb.Forms.Field.GetFieldById(GetInteger("SubmitData.FieldID")).Active){

//Render the field in the receipt

}

 
Lise T. Pedersen
Reply

Hi Nicolai

In basic, its the standard cshtml mail template I am using, I have only changed the link-color and a logo. And at some time you helped me adding some code, so that the "brødtekst" fields isn't rendering in the mail. But I am not sure how to combine these tings with the new "if sentence", so that it still works both?

And I can't find the bug and bugfix you are referring to?

Thanks,

Lise

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Lise

Attached the condition implemented. You can find the TFS number at some time later today. They only get replicated once in a while.

BR Nicolai

Votes for this answer: 1
 
Lise T. Pedersen
Reply

Hi again, Nicolai!

 

Unfortunately, I was a little to quick marking your reply as the answer.

I get this error message in the mail:

Error compiling template "Forms/Mail/DefaultMail_TT.cshtml"

Line 399: The type or namespace name 'Forms' does not exist in the namespace 'Dynamicweb' (are you missing an assembly reference?)

And error 399 is the new lines in the template. See attached file.

I hope you have an idea of, where the error can be - my solution is DW8, is this important?

Thanks,

Lise

14-09-2017_14-20-53_DefaultMail_tt.jpg
 
Nicolai Pedersen
Reply
This post has been marked as an answer

Which Dynamicweb version are you using?

If DW8 change the line to Dynamicweb.Modules.Forms

Votes for this answer: 1
 
Lise T. Pedersen
Reply

And this was working! Thank You!

 

You must be logged in to post in the forum