HEX
Server: Apache
System: Linux clpupre 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64
User: undanet (1000)
PHP: 7.4.3
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/undanet/www//PortalEmpleo/src/Controller/UtilsController.php
<?php

namespace PortalEmpleo\Controller;

require __DIR__ . '/../../vendor/autoload.php';

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use PortalEmpleo\Repository\DBUtilRepository;

class UtilsController extends AbstractController
{
    public $load;

    public function __construct()
    {
    }

    private function pintarCombobox($html)
    {
        echo $html;
    }

    private function generarHTML($lvalorescombo)
    {
        //generar el codigo html del combo y devolverlo
        $htmlcombo = '<select name="slct' . $lvalorescombo['NombreCombo'] . '" id="slct' . $lvalorescombo['NombreCombo'] . '">';
            foreach ($lvalorescombo['Valores'] as $val) {
                $v1 = json_decode(array_shift($val));
                $v2 = array_shift($val);
                $htmlcombo = $htmlcombo . '<option value="' . $v1 . '" ';
                if($v2==$lvalorescombo['ValorSelected']){
                    $htmlcombo = $htmlcombo . ' selected>';
                }
                else{
                    $htmlcombo = $htmlcombo . ' >';
                }
                $htmlcombo = $htmlcombo . $v2 . '</option>';
            }
        $htmlcombo = $htmlcombo . '</select>';

        return $htmlcombo;
    }

    public function cargaCombobox($nombreCombo, $lang, $valSelected)
    {
        $dbUtilRepository = new DBUtilRepository();
        $lvalorescombo = call_user_func(array($dbUtilRepository, 'cargaComboBox'), $nombreCombo, $lang);

        //modificar el selected si viene como parametro
        $lvalorescombo["ValorSelected"] = $valSelected;

        if(isset($lvalorescombo)){
            $html = $this->generarHTML($lvalorescombo);  //Despues de modificar, generamos el codigo html
            $this->pintarCombobox($html);
        }
    }
}
    
?>