访问视图中的数组值

时间:2012-02-06 19:05:10

标签: zend-form-element

I have the following code in zend:

 $arrErrors=array();
     if (!empty($this->post['submit']))
    {
        // Each time theres an error, add an error message to the error array
           // using the field name as the key.
          if (empty($this->post['client_name']))
          $arrErrors['client_name'] = "Please Enter Client's name as it appears in the carrier software";
    }

如果我在控制器中设置$ this-> view-> arrErrors = $ arrErrors, 我可以在视图中以$ this-> arrErrors ['client_name']的形式访问它吗?

1 个答案:

答案 0 :(得分:0)

我为一个愚蠢的问题道歉。

这是正确的方法:

$this->view->arrErrors=arrErrors['client_name'];

在控制器中使用上述代码