Posted by nick on October 28, 2011 at 9:31 am
If the inline errors from zend validator are not displaying after submitting your form, you may need to add the “Errors” decorator to the form like
//apply decorators to each element.
foreach ($elements as $fieldName => $element) {
$element->setDecorators(array('ViewHelper','Errors',array()));
}
Also be sure the validation is taking place on your form after submission. The controller should look something like this (use the isValid() method)
public function createNewUserAction()
{
$form = new User_Form_CreateUserForm();
if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
$params = $form->getValues();
//save the user
$this->view->messages = array('User successfully saved.');
$this->_redirect('user/user-admin');
}
}
$this->view->form = $form;
}
Continue Reading
Posted by nick on July 2, 2011 at 3:07 pm
I came across the following error today while reorganizing my zend framework application:
“Action Helper by name Agent not found”. This error occurred when I tried to use an action helper in a controller file. When it looked for the “redirector” helper, it decided to look for a helper named “_agent” instead.
How did I get here? Previously on this site, I was not using Zend_Auth, so I called php’s session_start() in the index file. I had to remove session_start() because I implemented Zend_Auth in one of the modules today. Apparently, helpers do not work if the session has not been started. Start the session by whichever method you choose and the error along with the missing helper issue will go away.
Continue Reading
Posted by nick on at 1:26 pm
I got to thinking that it didn’t make sense to have a common /forms directory that would share forms between two modules when the forms would not be shared. A /forms directory within the specific module directory seemed more appropriate. The documentation on this isn’t very clear, but after some digging and trial and error I figured it out.
First, the directory structure. Notice the location of the forms directories.
/Application
/modules
/default
/controllers
/forms
/views
/admin
/controllers
/forms
/views
First, add the two below lines to your application.ini file.
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
Second, create a boostrap file for each module. The file, named Bootstrap.php, should be placed in the root of the module directory and the class name should be {module name}_Boostrap. This bootstrap file will cause zend framework to automatically add the new forms directory to the autoloader.
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {}
Third, add for form class to the /forms directory. A login form would have a filename of Login.php and a class name of {module name}_Form_Login.
class Admin_Form_Login extends Zend_Form
Lastly, call your form from a controller file from within the same module.
$form = new Admin_Form_Login();
Be careful if you’re adding a Bootstrap.php file to the default module! From Zend:
The reason that the default module is skipped is because the documented use case – particularly how we setup an application in Zend_Tool – is that the default module is directly beneath application/ and contains the application bootstrap. If we then allow loading the default module’s bootstrap… we get into a recursive loop.
Continue Reading
Posted by nick on June 27, 2011 at 7:56 am
Download the remote file
scp my_username_on_remote_server@remote_server_ip_address:fullPathToFileOnRemoteServer pathToPutFileOnLocalMachine
If the file was zipped, then we’ll need to unzip it locally
gunzip -f pathToFileOnLocalMachine
Then load the data into the database
mysql -u root -p -h localhost databaseName < pathToUnzippedFileOnLocalMachine
Continue Reading
Posted by nick on June 23, 2011 at 9:41 am
Get into an infinite loop or query that’s taking longer than your patience will allow? Using mysql’s “kill” command will be helpful in this case. First log into mysql and view the process list “select * from information_schema.processlist;” . View the list of processes and identify the process id number of the process you want to stop, then run “kill (process id);”. Be careful when stopping queries other than selects because you may run into some data corruption.
Continue Reading