8

当我创建动作然后单击它时,我得到 js 错误

未捕获的类型错误:无法读取未定义的属性“任务”(在 chrome 中)
类型错误:b 未定义(在 ff 中)

我的代码是:

视图.html.php

<?// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');


class ObshViewObsh extends JView
{

    function display($tpl = null)
    {

        $task = JRequest::getVar('task', '');
        switch($task){            
            case 'config': $this->config();break;
            default: $this->windows();
        }

        parent::display($tpl);
    }

    function windows(){
        JToolBarHelper::title( JText::_( 'Общежития' ), 'generic.png' ); 
        JToolBarHelper::custom('config','options','','Настройки',false); //<<< --- this link doesn't work

    }

     function config(){
        JToolBarHelper::title( JText::_( 'Общежития - настройка компонента' ), 'generic.png' );
        JToolBarHelper::apply('edit_config');
        JToolBarHelper::cancel('cancel');    
    }          

}

控制器.php

<?php
 error_reporting(E_ALL);
// No direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');


class ObshController extends JController
{       

    function config(){
        JRequest::setVar( 'view', 'obsh' );
        JRequest::setVar( 'layout', 'config'  );
        JRequest::setVar( 'hidemainmenu', 1 );
        parent::display();
    }        
}
4

1 回答 1

13

答案很简单……

我忘了在视图中添加表单

<form action="index.php" method="post" name="adminForm">

    something

    <input type="hidden" name="option" value="com_obsh" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="boxchecked" value="0" />
</form>
于 2012-08-25T11:06:36.240 回答