2012-11-03 32 views
0

我創建的Joomla組件和我有問題,在一個視圖中從後的Joomla GET POST數據

accesing數據我有6個收件箱,其中3是由JTable類chandled和多數民衆贊成不錯,但其他3我想到過程中,我的領域:

<input id="jform[team1_goals_players]" class="" type="hidden" name="jform[team1_goals_players]" value="2,2," aria-invalid="false"> 
<input id="jform_team1_goals" class="required" type="text" value="4" name="jform[team1_goals]" aria-required="true" required="required" aria-invalid="false"> 

第一個是場,我要處理和第二由JTable類使用

$sth = JRequest::get('team1_goals_players'); 

$某物chandled爲空

,我應該用JRequest來獲取價值等2

回答

2

$sth是空的,因爲沒有在form.You像team1_goals_players沒有變量必須嘗試像這個 - 第一個得到jform,然後從jform讀team1_goals_players

$post = JRequest::get('jform'); 
$sth = $post['team1_goals_players']; 

更多關於JRequest

+1

好吧,與JRequest :: getVar一起工作,非常感謝 – Viszman

+3

對於Joomla 2.5 JRequest已被棄用。您應該使用JInput來代替(請參閱http://docs.joomla.org/Retrieving_request_data_using_JInput) –

8

JRequest在2.5中已棄用。

$jinput = JFactory::getApplication()->input; 
$post = $jinput->get('jform', array(), 'array'); 
$sth = $post['team1_goals_players']; 
+1

這應該是:$ jinput = JFactory :: getApplication() - > input; –