ASCX/Macros in Form field default values

Aaron Fickes asked on January 29, 2015 19:44

I have a site that was upgraded from a previous version of Kentico to 8.1. In the old site I had a bizform with a hidden field, and in the field definition in the bizform I had the default value set to a custom macro, like this:

{% CurrentNode.GetCourseNameFromQueryString() #%}

The custom macro works in other places, but not here. What it does is pull an ID from the querystring and go get the name of a product from the database.

It used to save data to the form like this:

Advertising Review

Now it stores the macro hash, like this:

{% CurrentNode.GetCourseNameFromQueryString() |(user)tyates@cordelllaw.com|(hash)a982e0f19e0bf85184c6371e3e81a5a7bcaaf3166adeb88ecfc8ecb98fdc2741%}

Has Kentico changed what is allowed in the default value field of bizforms? I can re-write this to store the value in session if I need to, but I'm hoping that I'm missing something simple.

Correct Answer

Jan Hermann answered on February 4, 2015 09:10

Hello,

you need to put your macro via the macro editor, so please hit the small black arrow next to the Default value label and add the macro there.

Best regards,
Jan Hermann

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on January 29, 2015 19:52

I believe with the upgrade you need to resign your macros. You can also set the macro to not need a signature by simply stating it like this:

{% CurrentNode.GetCourseNameFromQueryString() @%}

Using an @ before the closing curly brace will tell the macro engine not to apply security to it.

1 votesVote for this answer Mark as a Correct answer

Aaron Fickes answered on January 29, 2015 21:35 (last edited on January 29, 2015 21:37)

No, it still just prints the macro as text in the field.

{% CurrentNode.GetCourseNameFromQueryString() @%}

Am I allowed to call macros in this field? It behaves as if macros are not parsed here.

This is what gets rendered to the screen:

<input
     name="p$lt$zoneContent$plceMainPlaceholder$p$lt$zoneContent$htmlPageContent$ucEditableText$BizFormControl1$Bizform1$CourseName$textbox" 
     type="text" 
     value="{% CurrentNode.GetCourseNameFromQueryString() @%}"
     maxlength="1024"
     id="p_lt_zoneContent_plceMainPlaceholder_p_lt_zoneContent_htmlPageContent_ucEditableText_BizFormControl1_Bizform1_CourseName_textbox" 
     class="form-control"
>
0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 30, 2015 10:38

Hi,

The macros are still supported in the default value of a field - could you please describe the field definition and settings?

0 votesVote for this answer Mark as a Correct answer

Aaron Fickes answered on January 30, 2015 22:38

Nothing unusual about the settings. Everything lower on the page below is empty.

Image Text

0 votesVote for this answer Mark as a Correct answer

Aaron Fickes answered on February 4, 2015 00:39

Any insight here?

0 votesVote for this answer Mark as a Correct answer

Aaron Fickes answered on February 9, 2015 18:08

That worked, thanks.

Not sure why it makes a difference, but entering it in the overlaid macro editor window works, while putting the value directly in the field does not.

0 votesVote for this answer Mark as a Correct answer

Suman Layek answered on May 23, 2016 19:57

Not working even I used macro editor to set the default value. The macro is working on any other section like Explanation text, Field caption etc but not in default menu. When I try to make the field as required the insert form asking for value and not saving. Please look into the below image to review the field settings. Can you please assist me to solve this bug.

Version Kentico 8.2 Field Settings: -

Image Text

Insert Form Result:-

Image Text

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.