January 19, 2007 on 12:09 am | In Zend Framework | No Comments

Form Input Validation

January 7, 2007 on 9:48 pm | In Zend Framework | 2 Comments

It is a big job to write the effective validation rule for form input, isn’t?

Unsupported operand types when call _getAllParams()

December 31, 2006 on 2:40 pm | In Zend Framework | 6 Comments

I think it is a bug, however, it seems that I can’t login into Zend Framework Wiki today. Anyway, here is what I have found.

When I call _getAllParams() in FormController, like

Code (php)
  1. $this->_getAllParams();
  2.  
  3.  

I got the error message as "unsupported operand types".

Finally, I found the problem in Zend\Controller\Request\Http.php   line 601

Code (php)
  1.   590   /**
  2.   591    * Retrieve an array of parameters
  3.   592   *
  4.   593    * Retrieves a merged array of parameters, with precedence of userland
  5.   594    * params (see {@link setParam()}), $_GET, $POST (i.e., values in the
  6.   595    * userland params will take precedence over all others).
  7.   596    *
  8.   597    * @return array
  9.   598    */
  10.   599    public function getParams()
  11.   600    {
  12.   601            return $this->_params + $_GET + $_POST;
  13.   602    }
  14.  

The reason is because $_GET and/or $_POST was NULL when getParams() was called.

Temporarily , I changed it as below:

Code (php)
  1. public function getParams()
  2. {
  3.  
  4.           if ( null !== $_GET && null !== $_POST) {
  5.                  return $this->_params + $_GET + $_POST;
  6.           } elseif ( null !== $_GET && null == $_POST) {
  7.                 return $this->_params + $_GET;
  8.           } elseif ( null == $_GET && null !== $_POST) {
  9.                 return $this->_params + $_POST;
  10.           }
  11.                 return $this->_params;
  12. }

Refactor-Step One

December 31, 2006 on 2:14 am | In Zend Framework | No Comments

By now, my  first  step of refactor for addAction(), editAction() etc. has been finished. They are all related FORM operation. First of all, I created a form controller which named FormController. Of course, the file name is FormController.php and the class name is FormController().

It looks like

Code (php)
  1.  
  2. class FormController extends Zend_Controller_Action
  3.  
  4. {
  5.    function init()
  6.    {
  7.     Zend::loadClass(‘Bookmark’);
  8.     Zend::loadClass(‘User’);
  9.    }
  10.    public function insertAction()
  11.    {
  12.  
  13.           $arg1  = $this->_request->getParam(‘arg1_name’, 0);
  14.           $args  = $this->_request->getParams();
  15.           …
  16.    }
  17. }
  18.  

in IndexController.php, the code would be

Code (php)
  1. function addAction()
  2. {              
  3.    $data = array
  4.    (   
  5.         ‘arg1_name’   => ‘arg1′,
  6.         ‘arg2_name’   => ‘arg2′,
  7.         ‘arg3_name’   => ‘arg3′
  8.    );
  9.        
  10.    $this->_forward(‘form’,‘insert’,$data);
  11. }

Zend Framework could not recognize index.php

December 22, 2006 on 9:40 am | In Zend Framework | 2 Comments

In RewriteRouter.php, after line 136 add

/** Added by Jason Qi Nov 28, 2006 */
        $tpath = $path;
        $tpath = strtolower($tpath);
        if (strstr($tpath, ‘.php’)) {
            $path = substr($path, 0, strpos($path, ‘.’));
        }

to eliminate .php from index.php

« Previous PageNext Page »
Since May 6,2007 We have Visitors
dog ramps

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^