为什么我在看到数据时得到空数组

时间:2013-07-22 00:04:00

标签: cakephp cakephp-2.0 cakephp-2.1

我的形式是

<?php

echo $this->Form->create('Vendor', array(
'url' => array_merge(array('action' => 'index'), $this->params['pass'])
));
echo $this->Form->input('vendor_name', array('div' => false,'empty'=>true));
echo $this->Form->input('is_finalized', array('div' => false,'empty'=>true));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

?>

我在控制器中有这个

var_dump($this->request);
当我查看它的var_dump时,

$ this-&gt;请求中有一个data属性。请看下面的转储。但是当我这样做的时候 的var_dump($这 - &GT;请求 - &GT;数据);我得到一个空数组。您可以在下面看到$ this-&gt;请求var_dump

下的公共数据

这是$ this-&gt; request

的var_dump
object(CakeRequest)[9]
  public 'params' => 
    array (size=5)
      'plugin' => null
      'controller' => string 'vendors' (length=7)
      'action' => string 'index' (length=5)
      'named' => 
        array (size=0)
          empty
      'pass' => 
        array (size=0)
          empty
  public 'data' => 
    array (size=1)
      'Vendor' => 
        array (size=2)
          'vendor_name' => string 'fudatools' (length=9)
          'is_finalized' => string '1' (length=1)
  public 'query' => 
    array (size=0)
      empty
  public 'url' => string 'vendors' (length=7)
  public 'base' => string '/hiVendors' (length=10)
  public 'webroot' => string '/hiVendors/' (length=11)
  public 'here' => string '/hiVendors/vendors' (length=18)
  protected '_detectors' => 
    array (size=11)
      'get' => 
        array (size=2)
          'env' => string 'REQUEST_METHOD' (length=14)
          'value' => string 'GET' (length=3)
      'post' => 
        array (size=2)
          'env' => string 'REQUEST_METHOD' (length=14)
          'value' => string 'POST' (length=4)
      'put' => 
        array (size=2)
          'env' => string 'REQUEST_METHOD' (length=14)
          'value' => string 'PUT' (length=3)
      'delete' => 
        array (size=2)
          'env' => string 'REQUEST_METHOD' (length=14)
          'value' => string 'DELETE' (length=6)
      'head' => 
        array (size=2)
          'env' => string 'REQUEST_METHOD' (length=14)
          'value' => string 'HEAD' (length=4)
      'options' => 
        array (size=2)
          'env' => string 'REQUEST_METHOD' (length=14)
          'value' => string 'OPTIONS' (length=7)
      'ssl' => 
        array (size=2)
          'env' => string 'HTTPS' (length=5)
          'value' => int 1
      'ajax' => 
        array (size=2)
          'env' => string 'HTTP_X_REQUESTED_WITH' (length=21)
          'value' => string 'XMLHttpRequest' (length=14)
      'flash' => 
        array (size=2)
          'env' => string 'HTTP_USER_AGENT' (length=15)
          'pattern' => string '/^(Shockwave|Adobe) Flash/' (length=26)
      'mobile' => 
        array (size=2)
          'env' => string 'HTTP_USER_AGENT' (length=15)
          'options' => 
            array (size=26)
              ...
      'requested' => 
        array (size=2)
          'param' => string 'requested' (length=9)
          'value' => int 1
  protected '_input' => string '' (length=0)

1 个答案:

答案 0 :(得分:0)

你错了

的var_dump($这 - &GT;请求); 替换为

的print_r($这 - &GT;请求 - &GT;数据);