lundi 15 novembre 2021

How to get CHtml::dropDownList value exactly after option is chosen

everyone. I am new to PHP and Yii framework and I have a problem. I have php file, which I want to create depending on user choices. The code below represents a dropdown list with driver names from my database:

            <div class="row top10">
                <div class="col-md-6 ">
                    <?php echo CHtml::dropDownList(
                        'driver-names',
                        $dropvalue,
                        (array)Driver::driverDropDownList(Driver::getUserId()),
                        array(
                            'class' => "form-control"
                        )
                    ) 
                    ?>
                </div>
            </div>

After choosing a certain name from the dropwodn I want to know which name is chosen and depending on its value to show different html. Something like that:

            <?php if($dropvalue=='George'):?>
                <label class="col-sm-2 control-label"><?php echo Driver::t("first check") ?></label>
                    <div class="col-sm-6">
                        <?php
                        echo CHtml::checkBox(
                            'yes and no',
                            $dropvalue=='George' ? true : false,
                            array(
                                'class' => "switch-boostrap"
                            )
                        )
                        ?>
                    </div>
            <?php endif;?>

I read the documentation about Yii and thought that it is enough to save the value into $dropvalue and then check it in if statement. But nothing is happening like that and my checkBox does not appear.




Aucun commentaire:

Enregistrer un commentaire