Issues with macro to populate year drop down in custom field

Brian Bailey asked on September 6, 2017 21:11

I am trying to create a custom field (within user settings class of the membership module) to contain the birth year of someone. I'd like to do a loop from 1920 to whatever the current year is.

I've tried the following macro and various other flavors without luck:

{% date = DateTime.Now.Year; z = 1920; while (z<date) {++z} #%}

I even just tried looping from 1920 to 2017 and couldn't get that to work

Should this be possible to do? Any thoughts on a better way to approach this requirement?

Correct Answer

Trevor Fayas answered on September 6, 2017 21:29

This works for me:

z = 1920; t=DateTime.now.year; while (z<t) {++z}

If you are using a macro data source, you may or may not need to put the {% %} around them when entering it in, as well as usually macro data sources require an object as the source, not a list of numbers.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Brian Bailey answered on September 6, 2017 22:49

Perfect. It was the extra brackets in there. Thanks very much!

0 votesVote for this answer Mark as a Correct answer

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