Jinput not working for joomla

601 Views Asked by At

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.

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

<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

$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. Can anyone please point me at the right direction?

1

There are 1 best solutions below

0
On

The Post data should be received in Controller not in view.

Once you submit the form it should have controller and model to handle the POST data.

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

Hope its helps..