<?php

/**
 * Questo file è parte di Pongho.
 *
 * @author Daniele De Nobili
 * @package Application\Admin
 */

namespace Application\Admin\Form;

/**
 * Campo select gerarchica.
 *
 * @deprecated
 */
class SelectHierarchyField extends SelectField
{
    /**
     * {@inheritdoc}
     */
    public function getViewCode()
    {
        $this->setItems();
        $attribute_value = $this->model->{$this->attribute_name};

        if (is_null($attribute_value)) {
            $attribute_value = $this->default;
        }

        $container = $this->get('subject')->getContainer();

        $code = $this->get('required', false) ? '' : ('<option value="">' . $this->get('default_label', '') . '</option>');
        $code .= $container->get('template_html')->selectHierarchy($this->items, $attribute_value, $this->get('excluded', []));

        return '<select name="' . $this->post_name . '" id="' . $this->post_name . '">' . $code . '</select>';
    }
}
