Component Creator custom fields

Ok. When creating a custom field:

Here's an example of the text that goes in the "The php for the getOptions method" box.

// gets the name and IDs of the description articles
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.title')));
$query->from($db->quoteName('#__content', 'a'));
$query->where($db->quoteName('a.state') . ' != 2');
$query->where($db->quoteName('a.catid') . ' = 24');
$query->order('a.id ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
\t$options[] = JHtml::_('select.option', '', 'Select an option');
\tforeach($items as $item)
\t{
\t\t$options[] = JHtml::_('select.option', $item->id, $item->title);
\t}
}

return $options;

In the table field, this is the field that your method above links to. #__content

In the Component field, put the name of your component; example com_regsix

In the value_field: put the field name from the table being accessed by the getOptions method that contains the field that you want to display in the listview. IN this case it is "title".

In the key field: put the field in the table being accessed by the getOptions method that contains the value that is being stored (not the table your getOptions method is accessing). In this example, it would be "id" from the #__content which is being stored in another table for sessions.

 

 

 

 

 

 

You have no rights to post comments