JForm::getInstance could not load file

你离开我真会死。 提交于 2019-12-12 12:10:52

问题


I am making a form component into joomla.In which i will put one textbox and one editor and one button. i create the view file for this form and the component is successfully install.but when i click to display this form onto the front end,there is an error display like:

"The requested page cannot be found. An error has occurred while processing your request.

You may not be able to visit this page because of:

an out-of-date bookmark/favourite a mistyped address a search engine that has an out-of-date listing for this site you have no access to this page Go to the Home Page

Home Page

If difficulties persist, please contact the System Administrator of this site and report the error below.

500 JForm::getInstance could not load file" thanks for your support


回答1:


1. First check your form xml-file

Front-end path: components\com_<name_of_component>\models\forms\<formname>.xml

Back-end path: administrator\components\com_<name_of_component>\models\forms\<formname>.xml

Example (Joomla 3.4.3): administrator\components\com_users\models\forms\group.xml

<?xml version="1.0" encoding="utf-8"?>
<form>
    <fieldset>
        <field name="id" type="hidden"
            default="0"
            required="true"
            readonly="true"
        />

        <field name="title" type="text"
            required="true"
            description="COM_USERS_GROUP_FIELD_TITLE_DESC"
            label="COM_USERS_GROUP_FIELD_TITLE_LABEL"
            size="40"
        />

        <field name="parent_id" type="groupparent"
            description="COM_USERS_GROUP_FIELD_PARENT_DESC"
            label="COM_USERS_GROUP_FIELD_PARENT_LABEL"
            required="true"
        />

        <field name="actions" type="hidden"
            multiple="true"
        />

        <field name="lft" type="hidden"
            filter="unset"
        />
        <field name="rgt" type="hidden"
            filter="unset"
        />
    </fieldset>
</form>

2. Check your model class

The method getForm() is responsible for loading the form (the form xml-file mentioned above).

Front-end path: components\com_<name_of_component>\models\<modelname>.php

Back-end path: administrator\components\com_<name_of_component>\models\<modelname>.php

Example (Joomla 3.4.3): administrator\components\com_users\models\group.php

/**
 * Method to get the record form.
 *
 * @param   array    $data      An optional array of data for the form to interogate.
 * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
 *
 * @return  JForm   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_users.group', 
        'group', 
        array(
            'control' => 'jform', 
            'load_data' => $loadData)
        );

    if (empty($form))
    {
        return false;
    }

    return $form;
}



回答2:


Check your xml file proper load and also check your view form add any extra xml form like (filter) then check it proper exists in models/forms folder



来源:https://stackoverflow.com/questions/27314306/jformgetinstance-could-not-load-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!