Php 如何从Joomla视图表单传递数据数组并在Joomla控制器中获取数据数组

Php 如何从Joomla视图表单传递数据数组并在Joomla控制器中获取数据数组,php,arrays,joomla,Php,Arrays,Joomla,在视图/default.php中: <form action="<?php echo JRoute::_('index.php?option=com_scheduler&view=report');?>" method="post" name="rform"> <input type="submit" class="button" value="Generate Report" /> <input type="hidden" name="task

视图/default.php
中:

<form action="<?php echo JRoute::_('index.php?option=com_scheduler&view=report');?>" method="post" name="rform">
<input type="submit" class="button" value="Generate Report" />
<input type="hidden" name="task" value="report.generate" />
<input type="hidden" name="data" value="<?php echo $this->epsiode; ?>" />
</form>
function generate(){
    $items = JRequest::getVar('data',array(), 'post', 'array');
    print_r($items);
}
输出是

Array ( [0] => Array )

请告诉我如何获取阵列数据。我使用的是Joomla 2.5.x版。

不清楚隐藏字段数据包含什么,但如果您只是回显一个数组,最终结果并不让我感到惊讶

我建议其中一种选择(可能有多种解决方案)

阵列
试试这个

<?php 
$content = $this->epsiode;
for($i=0;$i<sizeof($content);$i++) { ?>
<input type="hidden" name="data[]" value="<?php echo $content[$i] ; ?>" />
<?php } ?>


使用
$requestData=JRequest::get('post')
post
get
data
)在您使用的任何控制器中。这将为您提供从您正在使用的表单发送过来的所有数据。确保这是表单发布到的控制器。Joomla在从任务重定向到视图时有一些奇怪的行为,这可能会给人留下这样的印象:您在某个地方丢失了数据


使用Joomla 3.1.1

感谢您的回复。但是当我尝试使用JRequest获取JSON编码的值时,比如,$data=JRequest::getVar('data',array(),'post','array');$items=json_decode($data);打印(项目);
<?php 
$content = $this->epsiode;
for($i=0;$i<sizeof($content);$i++) { ?>
<input type="hidden" name="data[]" value="<?php echo $content[$i] ; ?>" />
<?php } ?>