I have included a hidden field in my form with this code:

<input type="hidden" name="reporter" value="<?php echo $this->item->reportid; ?>" />  

but I can't access it in my view.html.php using this code:

$sample = $_POST['reporter'];

Is there something I missed? Does this have something to do with Joomla?

UPDATE #1: I used this code below regarding JInput but still I can't get the value for reporter.

$input = JFactory::getApplication()->input; 
$test = $input->get('reporter');
  • 2
    You don't use $_POST with Joomla, please read the documentation on how to get post variables
    – Lodder
    Feb 4 '15 at 9:56
  • please check my update Feb 4 '15 at 10:01
  • please cross check the form method and action url
    – Nick
    Feb 4 '15 at 10:13
  • What should I check in the action url @Nick Feb 4 '15 at 10:15
  • Can you access other data from your form? Because the code itself looks fine. I don't think the issue comes from that.
    – Bakual
    Feb 5 '15 at 10:12

Why you need to access it in your View? Probably the best way to access it is in your Controller.

Anyway please be sure that you post your data right as @Lodder mentioned. Check that your action attribute contains the right component and task. Or you should put some hidden fields in you form to post it to the needed controller and task:

<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="controller.task" />
  • Completely agree. First of all why you want to get POST data in view.html.php. Whatever you want to access in this file should get from model itself.
    – atpatil11
    Feb 4 '15 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.