1

Iam suffering from Zend_validate ,when ever I write a form and try to add validators , the only thing that works for me if I submit the form with no values , it will show error msg , but if I submit good values it will stuck for sometime and then give fatal error msg saying Maximum execution time 30 seconds is exceeded in /Applications/MAMP/htdocs/MyApplicationFolderName/library/Zend/Validate/Hostname.php on line 608
Please help my controller action code is

public function createAction()
  {
    // action body

    $roleService=new User_Service_RoleService($this->em);



    $userForm=new User_Form_UserForm($roleService->listAllRoleNames());
    $userForm->startForm();

    $userForm->setAction('create');
    $userForm->setMethod('post');



    if($this->getRequest()->isPost() )
    {
        if($userForm->isValid($this->getRequest()->getPost()))
        {
        $this->userAccountService->createUser($this->getRequest()->getParams());
        $this->_forward('confirm');
        }

    }





    $this->view->form=$userForm;



}

and my form class code is

class User_Form_UserForm extends Zend_Form {
//put your code here

private $roles;

public function __construct($options = null) {
    parent::__construct($options);


    $this->roles=$options;


}


public function startForm()
{

    $idForm=new Zend_Form_Element_Hidden('id');
    $this->addElement($idForm);

     ///////////          
    $userEmailForm=new Zend_Form_Element_Text('email');
    $userEmailForm->setRequired(TRUE);
    $userEmailForm->setLabel('Email');

    $emailValidator=new Zend_Validate_EmailAddress();

   // $emailValidator->setOptions(array('domain' => FALSE));


    $userEmailForm->addValidator($emailValidator,false);

    $userEmailForm->setAttrib('size', 25);

    $userEmailForm->setFilters(array(new Zend_Filter_StringToLower(),
                                     new Zend_Filter_StringTrim())

                               );

    $this->addElement($userEmailForm);



}



 }

This is small part of my form its so simple but not working Iam using MAMP PHP 5.3.5 because of Doctrine2 and name spaces

Please any help will be really appreciated .

Note I also tried other validators like string length and the same error showed.

AlaaQash
  • 15
  • 5
  • 2
    Possiblee duplicate of http://stackoverflow.com/questions/5400154/iconv-strlen-function-causing-execution-timeout-running-on-mamp - some solutions there that might help you. – Tim Fountain Aug 07 '11 at 23:32
  • you are right they seem to suffer from the same thing but , I dont see any answers there , they say its a MAMP bug ,so I have to install another version of PHP or use PHP 5.2 which I can not because of name spaces and doctrine2 , ZendCast videos are running on Mac using MAMP ,it was not mentioned through the tutorial anything regarding this , I have also books of Zend nothing there also , so if anybody could solve this issue I will really really appreciate – AlaaQash Aug 07 '11 at 23:44
  • Thanks Tim its confirmed to be same problem iconv_strlen() is not working on Mac OSX , thanks for pointing to the reason of this I will try to solve it , but if there is a short way please tell me – AlaaQash Aug 07 '11 at 23:53

2 Answers2

4

"I actually just found the answer to this one:

The version of PHP 5.3 that ships with MAMP has a bug in iconv_strlen() that causes a "do { ... } while (false);" loop in the validator to run infinitely. I just switched my PHP version to 5.2, as it's closer to production anyway, and it works. If you need the 5.3, though, you will have to upgrade your PHP installation in MAMP. I haven't tried it, but the following link was highly recommended:

http://www.davidgolding.net/cakephp/upgrading-php-in-mamp.html

Hope that all helps."

Source: http://forum.mamp.info/viewtopic.php?f=2&t=12189

pahan
  • 2,445
  • 1
  • 28
  • 36
Brie
  • 56
  • 2
0

I worked out the problem by not using mamp , and start using Zendserver CE free Edition http://www.zend.com/en/products/server-ce/downloads , and by going through the steps described on this link http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/ I could edit my root document for zend server to USERS/sites/ I run Zendframework validation and it worked nicely , I like mamp but I develope on Zend and zend use iconv_strlen() ,

the other way to solve this issue is by installing PHP but I found that not an easy solution , or you can use macports and I didnot want to go that way, since Iam using zendframework I needed something related to it so I used zendServer which is so far the cleanest solution .

AlaaQash
  • 15
  • 5