How to leave the required selection? and also by default the first available option?

0

I have a system in php that generates selects according to the information of the database, in case I would like to leave these selects obligatory because they do not go unnoticed and also always leave the first option selected as the default.

below the code where the selects are created:

if(get_field('atributos')){
    $selects = array();
    $i=0;
    $atributos = explode(PHP_EOL,get_field('atributos'));

    foreach($atributos as $atributo){
        $opcoes = explode(':',$atributo);
        $name = $opcoes[0];
        if(!empty($opcoes[1])){
            $opcoes = explode(';',$opcoes[1]);
        }
        $selects[$i] = array('name'=>$name,'options'=>$opcoes); 
        $i++;
    
asked by anonymous 25.05.2018 / 20:50

0 answers