Source for file model.php
Documentation is available at model.php
* @package FrameworkOnFramework
* @copyright Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
// Protect from unauthorized access
require_once JPATH_LIBRARIES .
'/joomla/form/fields/sql.php';
* Form Field class for FOF
* Generic list from a model's results
* @package FrameworkOnFramework
* Method to get the field options.
* @return array The field option objects.
// Initialize some field attributes.
$key =
$this->element['key_field'] ? (string)
$this->element['key_field'] :
'value';
$value =
$this->element['value_field'] ? (string)
$this->element['value_field'] : (string)
$this->element['name'];
$translate =
$this->element['translate'] ? (string)
$this->element['translate'] :
false;
$applyAccess =
$this->element['apply_access'] ? (string)
$this->element['apply_access'] :
'false';
$modelName = (string)
$this->element['model'];
$nonePlaceholder = (string)
$this->element['none'];
if (!empty($nonePlaceholder))
$options[] =
JHtml::_('select.option', JText::_($nonePlaceholder), null);
// Process field atrtibutes
$applyAccess =
in_array($applyAccess, array('yes', 'on', 'true', '1'));
// Explode model name into model name and prefix
$config =
array('savestate' =>
0);
$model->applyAccessFiltering();
// Process state variables
foreach ($this->element->children() as $stateoption)
// Only add <option /> elements.
if ($stateoption->getName() !=
'state')
$stateKey = (string)
$stateoption['key'];
$stateValue = (string)
$stateoption;
$model->setState($stateKey, $stateValue);
// Set the query and get the result list.
$items =
$model->getItemList(true);
// Build the field options.
foreach ($items as $item)
$options[] =
JHtml::_('select.option', $item->$key, JText::_($item->$value));
$options[] =
JHtml::_('select.option', $item->$key, $item->$value);
// Merge any additional options in the XML definition.
Documentation generated on Tue, 19 Nov 2013 15:08:38 +0100 by phpDocumentor 1.4.3