Answers.Body: <p>You're close! If there's one thing I've learned about Twig, it's easy to overthink it... </p>
  
  <p>Create an array with the first date, then <a href="http://twig.sensiolabs.org/doc/filters/merge.html" rel="nofollow">merge</a> the rest of dates into the same array with a for loop. Just increment the day in the range:</p>
  
  <pre><code> {% set rangeOfDates = [ now|date("l dS F Y") ] %}
  
   {% for i in range (1,13) %}
  
       {% set rangeOfDates = rangeOfDates|merge( [ now|date_modify("+" ~ i ~ " day")|date("l dS F Y") ]) %}
  
  {%endfor%}
  </code></pre>
  
  <p>Then in your forms macro:</p>
  
  <pre><code>{{ forms.select({
      options: rangeOfDates
  }) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-24T21:21:28.923Z
Answers.Text: So simple, twig rocks. One problem with the above code is that the variable `dates` in the for loop doesn't exist, it needs to be rangeOfDates. If you update you answer with `{% set rangeOfDates = rangeOfDates|merge( [ now|date_modify("+" ~ i ~ " day")|date("l dS F Y") ]) %}` I will mark it as correct.
Answers.UserDisplayName: since1976
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-25T20:16:29.250Z
Answers.Text: Oops thank you, fixed! In the spirit of clarify I had changed the variable name at the last minute but of course forgot to change it in that critical spot!
Answers.UserDisplayName: RitterKnight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-24T05:08:01.717Z
Answers.LastActivityDate: 2015-06-25T20:15:10.853Z
Answers.LastEditDate: 2015-06-25T20:15:10.853Z
Answers.UserDisplayName: RitterKnight
Body: <p>I'm looking to create a select (dropdown) form field that includes the days and dates for the next 14 days, starting from today, as options. </p>
  
  <p>My initial thoughts on how to construct this would be to set today <code>{% set today = now|date("l dS F Y") %}</code> and then set a date 13 days from now <code>{% set finalDate = now|date_modify("+13 day")|date("l dS F Y") %}</code> and then somehow put that into a range loop. It is the last part I'm having trouble getting working, if it is at all possible.</p>
  
  <p>Once I have that range I would ultimately like to pass it as option values to the <a href="https://craftcms.stackexchange.com/questions/10307/how-can-i-add-an-option-group-to-the-select-macro-from-craftcms-forms-macros">select macro mentioned in another question</a> like so:</p>
  
  <pre><code>{{ forms.select({
      options: ['Today', 'Tomorrow', ...]
  }) }}
  </code></pre>
  
  <p>Thanks</p>
  
Tags: <datetime><macro><range>
Title: How would I create a select element with the 14 days from today as options
ThreadText: # How would I create a select element with the 14 days from today as options
  
  (Asked by: username_0 on 2015-06-24)
  
  I'm looking to create a select (dropdown) form field that includes the days and dates for the next 14 days, starting from today, as options.
  
  My initial thoughts on how to construct this would be to set today `{% set today = now|date("l dS F Y") %}` and then set a date 13 days from now `{% set finalDate = now|date_modify("+13 day")|date("l dS F Y") %}` and then somehow put that into a range loop. It is the last part I'm having trouble getting working, if it is at all possible.
  
  Once I have that range I would ultimately like to pass it as option values to the [select macro mentioned in another question](https://craftcms.stackexchange.com/questions/10307/how-can-i-add-an-option-group-to-the-select-macro-from-craftcms-forms-macros) like so:
  
  ```
  {{ forms.select({
      options: ['Today', 'Tomorrow', ...]
  }) }}
  
  ```
  
  Thanks
  
  **Tags:** datetime, macro, range
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-24. Score: 5 | Accepted answer
  
  You're close! If there's one thing I've learned about Twig, it's easy to overthink it...
  
  Create an array with the first date, then [merge](http://twig.sensiolabs.org/doc/filters/merge.html) the rest of dates into the same array with a for loop. Just increment the day in the range:
  
  ```
   {% set rangeOfDates = [ now|date("l dS F Y") ] %}
  
   {% for i in range (1,13) %}
  
       {% set rangeOfDates = rangeOfDates|merge( [ now|date_modify("+" ~ i ~ " day")|date("l dS F Y") ]) %}
  
  {%endfor%}
  
  ```
  
  Then in your forms macro:
  
  ```
  {{ forms.select({
      options: rangeOfDates
  }) }}
  
  ```
  
  > **Comments:**
  > **username_0**: So simple, twig rocks. One problem with the above code is that the variable `dates` in the for loop doesn't exist, it needs to be rangeOfDates. If you update you answer with `{% set rangeOfDates = rangeOfDates|merge( [ now|date_modify("+" ~ i ~ " day")|date("l dS F Y") ]) %}` I will mark it as correct.  
  > **username_1**: Oops thank you, fixed! In the spirit of clarify I had changed the variable name at the last minute but of course forgot to change it in that critical spot!  
  
  ---
  
  