src/Generators/HtmlGenerator.php
public function makeSelected($config, $selected, $custom)
    {
        $options = $prefix = $suffix = '';

        if (isset($config['config']['multiple'])) {
            $custom = 'multiple';
            $config['name'] = $config['name'].'[]';
        }

        if (config('form-maker.form.orientation') === 'horizontal') {
            $prefix = '<div class="'.config('form-maker.form.input-column').'">';
            $suffix = '</div>';
        }

        foreach ($config['config']['options'] as $key => $value) {
            $selectedValue = '';

            if (isset($config['config']['multiple']) && is_object($selected)) {
                if (in_array($value, $selected->toArray())) {
                    $selectedValue = 'selected';
                }
            } else {
                if ($selected == '') {
                    $selectedValue = ((string) $config['objectValue'] === (string) $value) ? 'selected' : '';
                } else {
                    if (isset($config['objectValue']) && is_array(json_decode($config['objectValue']))) {
                        $selectedValue = (in_array($value, json_decode($config['objectValue']))) ? 'selected' : '';
                    } else {
                        $selectedValue = ((string) $selected === (string) $value) ? 'selected' : '';
                    }
                }
            }

            $options .= '<option value="'.$value.'" '.$selectedValue.'>'.$key.'</option>';
        }

        return $prefix.'<select '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'">'.$options.'</select>'.$suffix;
    }
public function makeSelected($config, $selected, $custom)
    {
        $options = $prefix = $suffix = '';

        if (isset($config['config']['multiple'])) {
            $custom = 'multiple';
            $config['name'] = $config['name'].'[]';
        }

        if (config('form-maker.form.orientation') === 'horizontal') {
            $prefix = '<div class="'.config('form-maker.form.input-column').'">';
            $suffix = '</div>';
        }

        foreach ($config['config']['options'] as $key => $value) {
            $selectedValue = '';

            if (isset($config['config']['multiple']) && is_object($selected)) {
                if (in_array($value, $selected->toArray())) {
                    $selectedValue = 'selected';
                }
            } else {
                if ($selected == '') {
                    $selectedValue = ((string) $config['objectValue'] === (string) $value) ? 'selected' : '';
                } else {
                    if (isset($config['objectValue']) && is_array(json_decode($config['objectValue']))) {
                        $selectedValue = (in_array($value, json_decode($config['objectValue']))) ? 'selected' : '';
                    } else {
                        $selectedValue = ((string) $selected === (string) $value) ? 'selected' : '';
                    }
                }
            }

            $options .= '<option value="'.$value.'" '.$selectedValue.'>'.$key.'</option>';
        }

        return $prefix.'<select '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'">'.$options.'</select>'.$suffix;
    }
public function makeSelected ( $ config , $ selected , $ custom ) { $ options = $ prefix = $ suffix = '' ; if ( isset ( $ config [ 'config' ] [ 'multiple' ] ) ) { $ custom = 'multiple' ; $ config [ 'name' ] = $ config [ 'name' ] . '[]' ; } if ( config ( 'form-maker.form.orientation' ) === 'horizontal' ) { $ prefix = '<div class="' . config ( 'form-maker.form.input-column' ) . '">' ; $ suffix = '</div>' ; } foreach ( $ config [ 'config' ] [ 'options' ] as $ key => $ value ) { $ selectedValue = '' ; if ( isset ( $ config [ 'config' ] [ 'multiple' ] ) && is_object ( $ selected ) ) { if ( in_array ( $ value , $ selected -> toArray ( ) ) ) { $ selectedValue = 'selected' ; } } else { if ( $ selected == '' ) { $ selectedValue = ( ( string ) $ config [ 'objectValue' ] === ( string ) $ value ) ? 'selected' : '' ; } else { if ( isset ( $ config [ 'objectValue' ] ) && is_array ( json_decode ( $ config [ 'objectValue' ] ) ) ) { $ selectedValue = ( in_array ( $ value , json_decode ( $ config [ 'objectValue' ] ) ) ) ? 'selected' : '' ; } else { $ selectedValue = ( ( string ) $ selected === ( string ) $ value ) ? 'selected' : '' ; } } } $ options .= '<option value="' . $ value . '" ' . $ selectedValue . '>' . $ key . '</option>' ; } return $ prefix . '<select ' . $ this -> processCustom ( $ custom ) . ' id="' . $ this -> getId ( $ config ) . '" class="' . $ config [ 'class' ] . '" name="' . $ config [ 'name' ] . '">' . $ options . '</select>' . $ suffix ; }
Make a select input.

@param array  $config
@param string $selected
@param mixed $custom

@return string
Make a select input .