$this->getRequest()->isPost() 返回 false [英] $this->getRequest()->isPost() return false

查看:22
本文介绍了$this->getRequest()->isPost() 返回 false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理最后一个开发人员创建了一个表单但没有使用$form"的现有代码,代码是:

 公共函数 indexAction() {......$objRequest = $this->getRequest();var_dump($objRequest->isPost()) ==>一直返回假如果 ($objRequest->isPost()) {$postedData = $objRequest->getPost();$inputData = new Zend_Filter_Input($this->filters, $this->validators,$objRequest->getPost());$params = $this->getRequest()->getParams();如果 ($inputData->isValid()) {.....

并在竞争中:

url(array('控制器' =>'指数','动作' =>'指数','模块' =>'默认',));?><form name="indexFormn" id="indexForm" method="POST" action="<?php echo $actionURL; ?>"><div class="AdminformDiv"><div class="errorbox"><?php如果 (!is_array($this->actionErrors)) {echo $this->actionErrors;}?>

<div><table border="0" cellpadding="0" cellspacing="0" style="width:700px"><tr><td style="width:128px">数量</td><td colspan="2">$ <?php echo $this->price;?>USD<td style="width:270px"></td></tr><tr>.....

这意味着他不使用任何表单类,但他喜欢旧的 php 方法,但使用 zend,所以他总是返回 false,我无法修复或检测问题出在哪里?

解决方案

我刚刚遇到了类似的问题,经过数小时的搜索找到了解决方案.检查您的开始和结束表单标签是否已填充表单.我不小心忘记删除我之前放在视图文件中的附加结束表单标记.

我不是百分百确定这如何影响我的表单,但附加的结束表单标签将我的方法更改为get",即使我将其设置为发布,因此当我点击提交时,它会跳过验证部分.

我希望这会有所帮助.

I'm working on an existing code who the last developer have created a form but without using a "$form", and the code is:

 public function indexAction() {
    .......

    $objRequest = $this->getRequest();
    var_dump($objRequest->isPost())  ==> all time return false
    if ($objRequest->isPost()) {

    $postedData = $objRequest->getPost();
    $inputData = new Zend_Filter_Input($this->filters, $this->validators,
                        $objRequest->getPost());

        $params = $this->getRequest()->getParams();
        if ($inputData->isValid()) {

   ..... 

and in the vie :

<?php $actionURL = $this->url(array(
'controller' => 'index',
'action'     => 'index',
'module'     => 'default',
));
?>

<form name="indexFormn" id="indexForm"  method="POST" action="<?php echo $actionURL; ?>">
<div class="AdminformDiv">
    <div class="errorbox">
        <?php
        if (!is_array($this->actionErrors)) {
            echo $this->actionErrors;
        }
        ?>
    </div>
    <div>
        <table border="0" cellpadding="0" cellspacing="0" style="width:700px">
            <tbody>
                <tr>
                    <td style="width:128px">Amount</td>
                    <td colspan="2">$ <?php echo $this->price;?> USD<td     style="width:270px">&nbsp;</td>
                </tr>
                <tr>

    .....

That means he don't use any form class but he do like the old php method but with zend,so all time he return false and I can't fix or detect where is the problem?

解决方案

I've just had a similar problem and found the solution after hours of searching. Check whether your opening and closing form tags are fulling enclosing the form. I accidentally forgot to remove an additional closing form tag that I previously put in the view file.

I'm not hundred percent sure how this affected my form but the additional closing form tag changed my method to 'get' even though I set it to post, thus when I hit submit, it would skip right passed the validation part.

I hope this helps.

这篇关于$this->getRequest()->isPost() 返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆