This can be bit daunting to call the Custom Field function outside of a form.
Please refere here to find how to Create a Custom Field function in Joomla.
The above method may not work sometimes, to resolve it, I have called a new helper function which pulled the same list (however we will have a function duplication which is not really ideal).
The help can be called as below but make sure that you have include the helper class path prior to call.
To include the helper class, add the below code on your com_mycomponent/mycomponent.php file.
Then, call the helper function as following:
Please refere here to find how to Create a Custom Field function in Joomla.
//Get GenreTypes from Custom Field Class JFormHelper::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields'); // works only if you set your field getOptions on public!! $genre_types = JFormHelper::loadFieldType('myComponentGenreTypes', false); $genre_types = $genre_types->getOptions()
The above method may not work sometimes, to resolve it, I have called a new helper function which pulled the same list (however we will have a function duplication which is not really ideal).
The help can be called as below but make sure that you have include the helper class path prior to call.
To include the helper class, add the below code on your com_mycomponent/mycomponent.php file.
// require helper files JLoader::register('MyComponentHelper', dirname(__FILE__) . DS . 'helpers' . DS . 'mycomponent.php');
Then, call the helper function as following:
$genre_types = MyComponentHelper::getGenreTypes();
No comments:
Post a Comment
Please post any queries and comments here.