Improved the plugin form builder, to allow multi form field relationships.

This commit is contained in:
2019-08-22 03:54:47 +02:00
parent c13c752abb
commit d2f94d84fa
65 changed files with 1225 additions and 431 deletions

View File

@ -774,7 +774,31 @@ abstract class ###Component###Helper
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],true);
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
@ -785,10 +809,8 @@ abstract class ###Component###Helper
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
// return the field xml
return $XML;
}
return false;
}

View File

@ -406,7 +406,7 @@ abstract class ###Component###Helper
* @return object
*
*/
public static function getFieldObject($attributes, $default = '', $options = null)
public static function getFieldObject(&$attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
@ -417,7 +417,31 @@ abstract class ###Component###Helper
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],true);
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
@ -428,10 +452,8 @@ abstract class ###Component###Helper
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
// return the field xml
return $XML;
}
return false;
}

View File

@ -242,6 +242,8 @@ class ###Component###Model###View### extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_###component###.###view###', $data);
}
return $data;

View File

@ -242,6 +242,8 @@ class ###Component###Model###View### extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_###component###.###view###', $data);
}
return $data;