<?php
/**
 * @package DJ-Catalog2-Yootheme
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */
defined('_JEXEC') or die;

use DJExtensions\DJCatalog2\YOOtheme\Builder\Source\ItemHelper;
$app = \Joomla\CMS\Factory::getApplication();
$fieldData = ItemHelper::getExtraField($props['field']);
if(empty($fieldData))return;
$formId = $app->input->get('searchId', $props['djc2filters_unique_id']);
$stringifyName = JFilterOutput::stringURLSafe($props['label']);
$fieldName = 'f_'.$fieldData->alias;

$currentOptions = $app->input->get($fieldName);

// Element
$el = $this->el('div', [

    'class' => [
        'uk-form-controls'
    ],
    'style' => [
        $props['css'],

    ]

]);

?>

<?= $el($props, $attrs) ?>
<?php if (isset($props['show_label']) && $props['show_label']) : ?>
    <label class="uk-form-label"><?php echo JText::_($props['label']); ?></label>
<?php endif; ?>
<div class="uk-form-control">
    <select class="uk-select <?php echo (($props['submit']) ? 'dj-content-filters-autosubmit' : '')  ?>"  name="<?php echo $fieldName ?>[]">
        <option value="0"><?php echo \JText::_('PLG_SYSTEM_DJC2YOOTHEME_SELECT_OPTION') ?></option>
        <?php if (count($fieldData->options)) : ?>

            <?php foreach ($fieldData->options as $option) : ?>
                <option <?php if(isset($currentOptions) && $currentOptions) echo((in_array($option->id, $currentOptions)) ? 'selected="selected"' : '') ?> value="<?php echo $option->id ?>"><?php echo (($option->value) ? $option->value : $option->value) ?></option>
            <?php endforeach; ?>

        <?php endif; ?>
    </select>



</div>


<?= $el->end() ?>

