0

I want to add a default selected option in the select tag
Here's the code:

->add('datefinProjet', 'date', array(
'label'=>'Date fin Projet :', 
'years' => range(date('Y') - 20, date('Y') - 100),
'empty_value' => array('years'=>'' , 'month' => '', 'day' =>'' )))

I want the select list to start with the empty value ''

1 Answer 1

1

You have a error in your empty_value parameter. Should be 'year', not 'years'

    $builder->add('datefinProjet', 'date', array(
        'label'=>'Date fin Projet :',
        'years' => range(date('Y') - 20, date('Y') - 100),
        'empty_value' => array('year' => '', 'month' => '', 'day' => '')
    ));

Source: Docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.