I have a dynamic select tag in my index.twig The code of the select is
<select name="portfolio" style="width: 265px; height:28px;">
<option selected="selected" value="default">Switch Your Portfolio</option>
{% for portfolio in portfolios %}
<option value={{ portfolio.id }}>{{ portfolio.portfolioName }}</option>
{% endfor %}
</select>
Now I have SwitchPortfolioType and I want to create this dynamic select inside my Type
class SwitchPortfolioType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('availability', 'choice', array(
'choices' => array(
//dynamic options here
),
'empty_value' => 'Switch your Portfolio',
));
}
}
How can I do this in Symfony2