HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers64/klimroosbudel.nl/wwwroot/lib/form/types/field_type_select.class.php
<?php
/**
 * field_type_text.class.php
 * Created by Komma Mediadesign.
 * Author: mike
 * Date: 13/12/13
 */

class Field_Type_Select extends Form_Field
{
    public function __construct()
    {
        parent::__construct();
    }

    /*
     * Create output
     * @return string
     */
    public function generate()
    {
        $output = '';
        $output .= '<div class="input_holder">
                        <label for="' . $this->name . '">' . $this->label . '</label>
                        <select name="' . $this->name . '" id="' . $this->name . '">
                            <option value="empty">Choose your brand</option>
                            ' . $this->getOptions() . '
                        </select>
                    </div>';

        // Set custom select
        $_SESSION['js_output'] .= '<script type="text/javascript">$(\'#' . $this->name .'\').customSelect();</script>';

        return $output;
    }

    private function getOptions()
    {
        $dummy = array('bavaria','dommelsch','grolsch','jupiler','heiniken');
        $output = '';

        foreach($dummy as $value)
        {
            $output .= '<option value="' . $value . '"';
            if($value == $this->value) $output .= ' selected';
            $output .= '>' . ucfirst($value) . '</option>';
        }
        return $output;
    }

    public function prepareForDb($value)
    {
        if($value == 'empty') $value = NULL;
        return $value;
    }
}