Form Input Validation
January 7, 2007 on 9:48 pm | In Zend Framework | 2 CommentsIt 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 CommentsI 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
-
$this->_getAllParams();
-
-
I got the error message as "unsupported operand types".
Finally, I found the problem in Zend\Controller\Request\Http.php line 601
-
590 /**
-
591 * Retrieve an array of parameters
-
592 *
-
593 * Retrieves a merged array of parameters, with precedence of userland
-
594 * params (see {@link setParam()}), $_GET, $POST (i.e., values in the
-
595 * userland params will take precedence over all others).
-
596 *
-
597 * @return array
-
598 */
-
599 public function getParams()
-
600 {
-
601 return $this->_params + $_GET + $_POST;
-
602 }
-
The reason is because $_GET and/or $_POST was NULL when getParams() was called.
Temporarily , I changed it as below:
-
public function getParams()
-
{
-
-
if ( null !== $_GET && null !== $_POST) {
-
return $this->_params + $_GET + $_POST;
-
} elseif ( null !== $_GET && null == $_POST) {
-
return $this->_params + $_GET;
-
} elseif ( null == $_GET && null !== $_POST) {
-
return $this->_params + $_POST;
-
}
-
return $this->_params;
-
}
Refactor-Step One
December 31, 2006 on 2:14 am | In Zend Framework | No CommentsBy 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
-
-
class FormController extends Zend_Controller_Action
-
-
{
-
function init()
-
{
-
Zend::loadClass(‘Bookmark’);
-
Zend::loadClass(‘User’);
-
}
-
public function insertAction()
-
{
-
-
$arg1 = $this->_request->getParam(‘arg1_name’, 0);
-
$args = $this->_request->getParams();
-
…
-
}
-
}
-
in IndexController.php, the code would be
-
function addAction()
-
{
-
$data = array
-
(
-
‘arg1_name’ => ‘arg1′,
-
‘arg2_name’ => ‘arg2′,
-
‘arg3_name’ => ‘arg3′
-
);
-
-
$this->_forward(‘form’,‘insert’,$data);
-
}
Zend Framework could not recognize index.php
December 22, 2006 on 9:40 am | In Zend Framework | 2 CommentsIn 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
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^