简体   繁体   English

JInput不适用于Joomla

[英]Jinput not working for joomla

I've been stuck on this problem with no clue as to why this doesn't work. 我一直被困在这个问题上,却不知道为什么它不起作用。

I'm using Joomla 2.5 and building my own component. 我正在使用Joomla 2.5并构建自己的组件。

I have a 'Books' and 'Book' view. 我有一个“书”和“书”视图。 'Books' lists all the books from the database and 'Book' is where I add/edit my book item. “图书”列出了数据库中的所有图书,“图书”是我添加/编辑图书项目的位置。 I'm trying to pass a value from 'Books' to 'Book' but it doesn't work. 我正在尝试将值从“书本”传递到“书本”,但是它不起作用。

I've set up an input text with a value to pass on. 我已经设置了带有值的输入文本,然后继续传递。

<input type="text" id="test" name="test" value="testvalue" />

views/books/tmpl/default.php views / books / tmpl / default.php

<form action="<?php echo JRoute::_('index.php?option=com_test'); ?>" method="post" name="adminForm">
        <table class="adminlist">
                <thead><?php echo $this->loadTemplate('head');?></thead>
                <tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
                <tbody><?php echo $this->loadTemplate('body');?></tbody>
        </table>
        <div>
                <input type="hidden" name="task" value="" />
                <input type="hidden" name="boxchecked" value="0" />
                <?php echo JHtml::_('form.token'); ?>

                <!-- For sorting -->
                <input type="hidden" name="filter_order" value="<?php echo $this->sortColumn; ?>" />
                <input type="hidden" name="filter_order_Dir" value="<?php echo $this->sortDirection; ?>" />
                <input type="text" id="test" name="test" value="testvalue" />
        </div>
</form>

And in my book view.html.php file views/book/view.html.php 在我的书view.html.php文件views / book / view.html.php中

$jinput = JFactory::getApplication()->input;
echo  'value:'.$jinput->get('test');

There will be no value. 没有价值。 I've tried $_POST('test') but it still doesn't work. 我已经试过$ _POST('test'),但仍然无法正常工作。 Can anyone please point me at the right direction? 谁能指出我正确的方向?

The Post data should be received in Controller not in view . Post数据应该在Controller而不在view接收。

Once you submit the form it should have controller and model to handle the POST data. 提交表单后,它应该具有控制器和模型来处理POST数据。

check this link and understand the work flow, then on your controller you can try the same code it will works. 检查此链接并了解工作流程,然后在控制器上尝试相同的代码即可使用。

Joomla MVC component structure Joomla MVC组件结构

Hope its helps.. 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM