在default.php中以隐藏的形式传递变量无效-joomla3


passing variable as hidden from default.php is not working - joomla 3

模块开发方面的新进展。我需要知道如何将一个变量从tmpl/default.php传递到mod.php,因为我在参考的教程中无法实现它。我就是这样使用的:

 tmpl/default.php (not the full code)
    <form action="index.php" method="post" id="sc_form">
    <input type="hidden" name="form_send" value="send" />
    <label>Your name:</label><br/>
    <input type="text" name="your_name" value="" size="40" /><br/><br/>
    <label>Your question:</label><br/>
    <textarea name="your_question" rows="5" cols="30"></textarea><br/><br/>
    <input type="submit" name="send" value="Send" />
    </form>
   -----------------------------------------------------------------------------------

mod_modulename.php

   $form_send = JRequest::getVar('form_send', 'notsend');
    switch($form_send){
    case 'send':     
    require(JModuleHelper::getLayoutPath('mod_<module_name>', 'sendok'));
    break;
    default:
    require(JModuleHelper::getLayoutPath('mod_<module_name>', 'default'));

}

非常感谢您的考虑。这对我来说将是一个很大的帮助…

JRequest方法在3中已弃用。请改用JInput。例如:

$input = JFactory::getApplication()->input;
$form_send  = $input->get('form_send', 'notsend');

希望它能帮助