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.

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

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。