Hi I'm looking to add new field attribute for my custom component.
<field type="myfield" mycustomattribute="somevalue" />
Then, I would like to render it in my HTML. Could someone help with it?
This is my custom FormField Code:
<?php
/*
* @package Joomla.Administrator
* @subpackage com_casestudy
*
* @Author Sahil Purav
* @contact [email protected]
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
class JFormFieldUpload extends JFormFieldFile {
/**
* The form field type.
*
* @var string
*
* @since 11.1
*/
protected $type = "upload";
/**
* The button text of the field.
*
* @var string
*/
protected $btnString;
public function getInput() {
// Initialize some field attributes.
$accept = !empty($this->accept) ? ' accept="' . $this->accept . '"' : '';
$size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
$class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
$disabled = $this->disabled ? ' disabled' : '';
$required = $this->required ? ' required aria-required="true"' : '';
$autofocus = $this->autofocus ? ' autofocus' : '';
$btnString = !empty($this->btnString) ? $this->btnString : JText::_('COM_HELPDESK_BROWSE_BUTTON');
$html = array();
$html[] = '<div id="file-upload">';
$html[] = '<button>' . $btnString . '</button>';
$html[] = '</div>';
return implode($html);
}
}