zoukankan      html  css  js  c++  java
  • [Yii Framework] Form with GET method

    All the content of this article only happend in Yii Framework!

    As we know, with a form, we can both use post and get to send the data. But in Yii, when creating a form as below: 

    <?php echo CHtml::beginForm('user/index','get'); ?>
      <?php echo CHtml::label('User','user01',array('class'=>'small'))?>
      <?php echo CHtml::textField('search','',array('id'=>'user01','class'=>'sText'))?>
      <?php echo CHtml::submitButton('Search',array('class'=>'butDef')); ?>
    <?php echo CHtml::endForm(); ?>

    after submited the form, we get nothing of the $_GET data! (except that we can get "r='user/index'").

    but why, this form seems everything ok!

    Then via google, i found the reason:

    A GET form action cannot include query parameters. You need to use hidden variables to generate the query paramaters. 

    here is the way to resolve it, add the code to the form:

    <?php echo CHtml::hiddenField('r','user/index')?>

    Have fun with Yii! 

  • 相关阅读:
    Python字符串
    MySQL触发器
    MySQL 1418报错解决办法
    数据库下载
    补码与反码
    二、八、十六进制之间的转换
    this 指向
    作用域 var 词法分析 arguments
    事件绑定的3种方式
    清浮动方法小结
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/2723852.html
Copyright © 2011-2022 走看看