Form Macros for default info in kentico 13

lawrence whittemore asked on May 4, 2023 18:22

Can you no longer use macros like {% CurrentUser.LastName #%} to auto fill in form data?

Recent Answers


Brenden Kehren answered on May 4, 2023 19:25

Macros for forms don't work with MVC.

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on May 4, 2023 19:58

Good to know. I really feel like the form options have drastically tanked in this version.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 4, 2023 20:40

Yes and no. I'm enjoying them a lot more due to the easy customizations I can do with them. I'm really fond of the form sections. We use them with every site we're on. Allows you to build the form pretty easy to make it fit with the rest of the site design without a lot of additional work.

Yes having some of the OOTB form controls and ease of creating form controls was awesome to have, but you can make them just as easy in v13 with mvc code.

The fact that you can't use macros on the MVC side of things is just a technology shift downfall. It was very unique to Kentico and was awesome but there are other ways to handle this and honestly, with all the browsers saving your info, it's pretty simple to fill forms now.

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on May 5, 2023 14:52

Maybe I am just approaching the way the forms work now wrong. As far as form sections, I only have 3, just different layout sizes 1, 2, and 3 columns. Not really sure what else we would do with those. The thing we miss the most are the layouts and alternate layouts. This is where we added javascript and things. Then the alternate layouts were nice for having fields and versions of the form that we only wanted to show in the admin area.

I would love to see an example of what others are doing with them.

The macros are not the end of the world, we were able to easily pull fields from the user that we pulled from AD. Things like employee number or department number that the user may not know off hand. I'm sure we can find work arounds, was just nice how easy it was before.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 5, 2023 15:15

Almost two years ago we had an Ask the Experts video that talked about form sections when they first came in Refresh 2. I've got a code repo here for that talk.

Regarding adding JS and custom styles, you can do this accroding to this documentation. It is based on widgets, however, you can always include that javascript in your fully bundled javascript too and just put triggers on specific elements.

Any global event handlers only need to be placed in the MVC code.

0 votesVote for this answer Mark as a Correct answer

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