Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/JForm/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/JForm/TFormfield.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\View\JForm;

defined('_JEXEC') or die;

// Display Joomla Form Field - Label, Form Control (Input), Description
class TFormfield
{
  	public $field;

    public $config = [];
    
    public function __construct($field, $config = [])
    {
        // $field is joomla form field object: __get(), getAttribute, __set
      	// $config - label_class, parent_class
        
        $this->field = $field;

        $this->config = $config; 
    }
    
    public function get_output()
    {        
        // Parent Class
        $parent_class[] = 'mb-3';
        $parent_class[] = $this->field->getAttribute('parentclass') ?? '';
        $parent_class[] = $this->config['parent_class'] ?? '';
        $this->field->__set('parentclass', implode(' ', $parent_class));

        $output = '';

        $this->get_label();

        $this->get_input();

        $output .= $this->field->renderField();
        
      	return $output;
    }

    public function get_label()
    {
        // Label Class
        $label_class[] = $this->field->getAttribute('labelclass') ?? '';
        $label_class[] = 'form-label';
        $label_class[] = $this->config['label_class'] ?? '';
        $this->field->__set('labelclass', implode(' ', $label_class));
        
        //return $this->field->label;
    }

    public function get_input()
    {   
        //return $this->field->input;
    }

    public function get_description()
    {
        $hiddenDescription = $this->field->getAttribute('hiddenDescription') == 'true';

      	if (!$this->field->description || $hiddenDescription)
        {
      		return;
        }

        $output = '<small class="form-text">' . $this->field->description . '</small>';

        return $output;
    }
}

/*
$this->field->renderField();
<div class="control-group"> // parentclass
    <div class="control-label">
        <label> </label> // labelclass
    </div> 
    <div class="controls"> 
        <input> // class
    </div>
</div>
*/