title: Variable variable name in twig
body: <p>I have a twig macro for creating a combo box form element like this :</p>
  
  <pre><code>{% macro select(name, label, choices, help, value) %}
  &lt;div class="control-group"&gt;
      &lt;label class="control-label" for="{{ name }}"&gt;{{ label }}&lt;/label&gt;
      &lt;div class="controls"&gt;
          {% for choice in choices %}
              {% if value is not empty and value == choice.id %}
                  &lt;option value="{{ choice.id }}" selected="selected"&gt;{{ choice.code }} - {{ choice.name }}&lt;/option&gt;
              {% else %}
                  &lt;option value="{{ choice.id }}"&gt;{{ choice.name }}&lt;/option&gt;
              {% endif %}
          {% endfor %}
          &lt;p class="help-block"&gt;{{ help }}&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endmacro %}
  </code></pre>
  
  <p>As you can see, it's not very flexible because I can only use objects with id and name field as the option value and label. Before migrating to twig, I use this PHP function :</p>
  
  <pre><code>function form_select($name, $label, $choices, $keycol, $valcol, $value=null, $help=null)
  { ?&gt;
  &lt;div class="control-group"&gt;
      &lt;label class="control-label" for="&lt;?php echo $name; ?&gt;"&gt;&lt;?php echo $label; ?&gt;&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;select name="&lt;?php echo $name; ?&gt;" class="span7" id="&lt;?php echo $name; ?&gt;"&gt;
              &lt;?php foreach ($choices as $choice) : ?&gt;
                  &lt;option value="&lt;?php echo $choice-&gt;$keycol; ?&gt;" &lt;?php if ($choice-&gt;$keycol == $value) echo "selected"; ?&gt;&gt;
                      &lt;?php echo $choice-&gt;$valcol; ?&gt;
                  &lt;/option&gt;
              &lt;?php endforeach; ?&gt;
          &lt;/select&gt;
          &lt;p class="help-block"&gt;&lt;?php echo $help; ?&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php }
  </code></pre>
  
  <p>With this function I can send arbitrary objects to the function and use it as the option value and label by passing the field name to the function (<code>$keycol</code> and <code>$valcol</code>) and accessing them via PHP's variable variable name feature (<code>$choice-&gt;$keycol</code> and <code>$choice-&gt;$valcol</code>).</p>
  
  <p>Is there anyway I can recreate this function as a twig macro?</p>