<?php
  /**
   * @version     1.0.0
   * @package     Joomla 4
   * @subpackage  Formea Element CountryState
   * @author      Feseur Sdn Bhd
   * @copyright   Copyright (C) 2010 - 2020 Feseur Sdn Bhd
   * @license     GNU/GPL, see LICENSE.php
   */

  namespace Joomla\Component\Formea\Plugins\Element\CountryState\Field;

  use Joomla\CMS\Factory;
  use Joomla\CMS\Form\FormField;
  use Joomla\CMS\Form\FormHelper;
  use Joomla\CMS\WebAsset\WebAssetManager;

  class FormeaElementCountrystateField extends FormField
  {
    /**
     * The name field type.
     *
     * @var    string
     */
    protected $type = 'FormeaElementCountrystate';



    public function __construct($form = null)
    {
      parent::__construct($form);
      $app = Factory::getApplication();
      /** @var WebAssetManager $wa */
      $wa = $app->getDocument()->getWebAssetManager();
      $registry = $wa->getRegistry();
      $registry->addRegistryFile('/components/com_formea/plugins/element/CountryState/joomla.asset.json');
      $wa->useScript('com_formea.element.CountryStateField');
    }

    protected function getLabel()
    {
      return '';
    }

    /**
     * Method to get the field input markup for the file field.
     * Field attributes allow specification of a maximum file size and a string
     * of accepted file extensions.
     *
     * @return  string  The field input markup.
     *
     * @note    The field does not include an upload mechanism.
     * @see     \Joomla\CMS\Form\Field\MediaField
     * @since   1.7.0
     */
    protected function getInput()
    {

      return '<formea-country-select-admin></formea-country-select-admin>';
    }

    /**
     * Method to get a control group with label and input.
     *
     * @param   array  $options  Options to be passed into the rendering of the field
     *
     * @return  string  A string containing the html for the control group
     *
     * @since   3.2
     */
    public function renderField($options = [])
    {
      return $this->getInput();
    }

  }
