joomla get post data

允我心安 提交于 2019-12-12 01:20:45

问题


I'm creating joomla component and i have problem with accesing data from post

in one view i have 6 inboxes 3 of them are chandled by JTable class and thats good, but other 3 i want to process, my fields:

<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">

first one is field that i want to process and second is chandled by JTable class by using

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

$sth is empty

where i should use JRequest to get that value and other 2


回答1:


$sth is empty because there is no variable like team1_goals_players in the form.You must try like this- first get jform and then read team1_goals_players from jform.

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

More about JRequest.




回答2:


JRequest is deprecated in 2.5.

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


来源:https://stackoverflow.com/questions/13211357/joomla-get-post-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!