dongliao8069 2014-02-12 10:30 采纳率: 0%
浏览 32
已采纳

从前端Joomla形式获得价值?

I am just learning Joomla here and it seems that I just cant get it, looked though heaps of websites and still nothing. Can someone explain it to me. I have a form on front end component view:

<form method="post" name="adminForm" id="adminForm">
  <div class="btn-group pull-right">    
    <select name="category" id="category" class="input-medium" onchange="document.adminForm.submit()">    
      <option value="10"><?php echo '10 By';?></option>
      <option value="14"><?php echo '14 By';?></option>                 
    </select>
  </div>                
</form>

Now is this format even correct and how do I now get the option value in model of that view? I tried using:

$category = $mainframe->getUserState( "category", $default_category );

but it seem to not working and I am only getting $default_category value in there.

Any advice or maybe a short example will be much appreciated.

Thank you.

  • 写回答

1条回答 默认 最新

  • doushan5245 2014-02-12 11:43
    关注
    $category = $mainframe->getUserState( "category", $default_category );
    

    This would work only if you have set the user state in the first place.

    To get the values from a POSTed form you can use

    $jinput = JFactory::getApplication()->input;
    $category = $jinput->get('category', $default_category, 'int');
    

    Suggest you read more about JInput here - JInput

    Note that in a typical form saving scenario you won't need to separately get request variables using JInput, since the saving is handled by Joomla if you name your tables and form inputs correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站