protected function getOptions()
	{
		// Initialize variables.
		$options = array();

		// 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;
		$query     = (string) $this->element['query'];

		// Get the database object.
		$db = App::get('db');

		// Set the query and get the result list.
		$db->setQuery($query);
		$items = $db->loadObjectlist();

		// Check for an error.
		if ($db->getErrorNum())
		{
			return $options;
		}

		// Build the field options.
		if (!empty($items))
		{
			foreach ($items as $item)
			{
				if ($translate == true)
				{
					$options[] = Dropdown::option($item->$key, App::get('language')->txt($item->$value));
				}
				else
				{
					$options[] = Dropdown::option($item->$key, $item->$value);
				}
			}
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::getOptions(), $options);

		return $options;
	}
protected function getOptions()
	{
		// Initialize variables.
		$options = array();

		// 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;
		$query     = (string) $this->element['query'];

		// Get the database object.
		$db = App::get('db');

		// Set the query and get the result list.
		$db->setQuery($query);
		$items = $db->loadObjectlist();

		// Check for an error.
		if ($db->getErrorNum())
		{
			return $options;
		}

		// Build the field options.
		if (!empty($items))
		{
			foreach ($items as $item)
			{
				if ($translate == true)
				{
					$options[] = Dropdown::option($item->$key, App::get('language')->txt($item->$value));
				}
				else
				{
					$options[] = Dropdown::option($item->$key, $item->$value);
				}
			}
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::getOptions(), $options);

		return $options;
	}
protected function getOptions ( ) { // Initialize variables. $ options = array ( ) ; // 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 ; $ query = ( string ) $ this -> element [ 'query' ] ; // Get the database object. $ db = App :: get ( 'db' ) ; // Set the query and get the result list. $ db -> setQuery ( $ query ) ; $ items = $ db -> loadObjectlist ( ) ; // Check for an error. if ( $ db -> getErrorNum ( ) ) { return $ options ; } // Build the field options. if ( ! empty ( $ items ) ) { foreach ( $ items as $ item ) { if ( $ translate == true ) { $ options [ ] = Dropdown :: option ( $ item -> $ key , App :: get ( 'language' ) -> txt ( $ item -> $ value ) ) ; } else { $ options [ ] = Dropdown :: option ( $ item -> $ key , $ item -> $ value ) ; } } } // Merge any additional options in the XML definition. $ options = array_merge ( parent :: getOptions ( ) , $ options ) ; return $ options ; }
Method to get the custom field options.
Use the query attribute to supply a query to generate the list.

@return  array  The field option objects.
Method to get the custom field options . Use the query attribute to supply a query to generate the list .