开发者

joomla 1.6 component creation error on model

开发者 https://www.devze.com 2023-04-10 04:35 出处:网络
I am trying to develop a joomla 1.6 component. I am getting the following error Fatal error: Call to a member function getKeyName() on a non-object in

I am trying to develop a joomla 1.6 component. I am getting the following error

Fatal error: Call to a member function getKeyName() on a non-object in D:\xampp\htdocs\lab\libraries\joomla\application\component\modeladmin.php on line 327

my model code is below

    <?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelform library
jimport('joomla.application.component.modeladmin');

/**
 * HelloWorld Model
 */
class CrudModelHiWorld extends JModelAdmin
{
    /**
     * Returns a reference to the a Table object, always creating it.
     *
     * @param   type    The table type to instantiate
     * @param   string  A prefix for the table class name. Optional.
     * @param   array   Configuration array for model. Optional.
     * @return  JTable  A database object
     * @since   1.6
     */
    public function getTable($type = 'Crud', $prefix = 'CrudTable', $config = array()) 
    {
        return JTable::getInstance($type, $prefix, $config);
    }
    /**
     * Method to get the record form.
     *
     * @param   array   $data       Data for the form.
     * @param   boolean $loadData   True if the form is to load its own data (default case), false if not.
     * @return  mixed   A JForm object on success, false on failure
     * @since   1.6
     */
    public function getForm($data = array(), $loadData = true)
    {   
        // Get the form.

        $form = $this->loadForm('com_crud.hiworld', 'hiworlds', array('control' => 'jform', 'load_data' => $loadData));
        if (empty($form)) 
        {
            return false;
        }           
        return $form;
    }
    /**
     * Method to get the data that should be injected in the form.
     *
     * @return  mixed   The data for the form.
     * @since   1.6
     */
    protected function loadFormData() 
    {
        // Check the session for previously entered form data.
        $data = JFactory::getApplication()->getUserState('com_crud.edit.hiworld.data', array());
        if (empty($data)) 
        {
            $data = $this->getItem();
        }
        return $data;
    }开发者_开发百科
}

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号