nwhiting wrote:
> 
> 
> Matthew Weier O'Phinney-3 wrote:
>> 
>> -- nwhiting <[EMAIL PROTECTED]> wrote
>> (on Friday, 31 October 2008, 07:34 AM -0700):
>>> I am having a small problem with validating input....
>>> I have everything setup correctly....but it seems that every time I
>>> submit
>>> the form it will always validate as true no matter what content is
>>> submitted
>>> in the form.
>> 
>> Nobody can help you unless you provide your form details...
>> 
>> -- 
>> Matthew Weier O'Phinney
>> Software Architect       | [EMAIL PROTECTED]
>> Zend Framework           | http://framework.zend.com/
>> 
>> 
> heres the code i am using....
> 
> protected function _createElement($name, $label, $type, $value = null,
> $desc = null)
>     {
>         $element = null;
>         switch($type)
>         {
>             case 'text':
>                 default:
>                 $element = new Zend_Form_Element_Text($name);
>                 $element->setOptions(array('maxlength' => 125));
>                 break;
>             case 'textarea':
>                 $element = new Zend_Form_Element_Textarea($name);
>                 $element->setOptions(array('rows' => 10, 'cols' => 35));
>                 break;
>             case 'password':
>                 $element = new Zend_Form_Element_Password($name);
>                 break;
>             case 'file':
>                 $element = new Zend_Form_Element_File($name);
>                 break;
>             case 'date':
>                 $element = new Zend_Form_Element_Text($name);
>                 $element->setOptions(array('dojoType' =>
> "dijit.form.DateTextBox"));
>                 break;
>             case 'countryList':
>                 $locale = new Zend_Locale('en_US');
>                 $countryList = ($locale->getCountryTranslationList());
>                 asort($countryList, SORT_LOCALE_STRING);
>                 $element = new Zend_Form_Element_Select($name);
>                 $element->addMultiOptions($countryList);
>                 break;
>             case 'stateList':
>                 $locale = new Zend_Locale('en_US');
>                 $stateList =
> array('AL'=>"Alabama",'AK'=>"Alaska",'AZ'=>"Arizona",'AR'=>"Arkansas",'CA'=>"California",'CO'=>"Colorado",'CT'=>"Connecticut",'DE'=>"Delaware",'DC'=>"District
> Of
> Columbia",'FL'=>"Florida",'GA'=>"Georgia",'HI'=>"Hawaii",'ID'=>"Idaho",'IL'=>"Illinois",'IN'=>"Indiana",'IA'=>"Iowa",'KS'=>"Kansas",'KY'=>"Kentucky",'LA'=>"Louisiana",'ME'=>"Maine",'MD'=>"Maryland",'MA'=>"Massachusetts",'MI'=>"Michigan",'MN'=>"Minnesota",'MS'=>"Mississippi",'MO'=>"Missouri",'MT'=>"Montana",'NE'=>"Nebraska",'NV'=>"Nevada",'NH'=>"New
> Hampshire",'NJ'=>"New Jersey",'NM'=>"New Mexico",'NY'=>"New
> York",'NC'=>"North Carolina",'ND'=>"North
> Dakota",'OH'=>"Ohio",'OK'=>"Oklahoma",'OR'=>"Oregon",'PA'=>"Pennsylvania",'RI'=>"Rhode
> Island",'SC'=>"South Carolina",'SD'=>"South
> Dakota",'TN'=>"Tennessee",'TX'=>"Texas",'UT'=>"Utah",'VT'=>"Vermont",'VA'=>"Virginia",'WA'=>"Washington",'WV'=>"West
> Virginia",'WI'=>"Wisconsin",'WY'=>"Wyoming");        $state = new
> Zend_Form_Element_Select('state');
>                 $element = new Zend_Form_Element_Select($name);
>                 $element->addMultiOptions($stateList);
>                 break;
> 
> 
>         }
> 
>         $element->setLabel(ucwords($label));
> 
>         if ($value != null)
>         {
>             $element->setValue($value);
>         }
> 
>         if ($desc != null)
>         {
>             $element->setDescription($desc);
>         }
> 
>         $element->addValidator('alnum')
>                 ->addValidator('regex', false, array('/^[a-z]/'))
>                 ->setRequired(true);
> 
>         return $element;
>     }
> 
> and rending a element is simply
> 
> $email = $this->_createElement('email', 'Email Address', 'text',
> $accountInfo['email']);
> 
> and when i enter anything that is not validating aganist that it still
> validates as true
> 
> and the code i am using to process the form is
> 
> if ( !$this->isMaster && $userId != $this->user->getUsername() )
>               {
>                       throwException(PERM_MSG);
>               }
>               // Render out the form and check the validation
>               elseif(!$this->_getParam('submit') || 
> $this->getRequest()->isPost() &&
> !$this->form->isValid($_POST))
>               {
>                       if ( ( null != $this->userGroupId && $this->userGroupId 
> == PRODUCER )
> || $this->user->getLevel() == PRODUCER )
>                       {
>                               if ($this->getRequest()->isPost())
>                               {
>                                       $accountInfo = $_POST;
>                               }
>                               else
>                               {
>                                       $sql = '"';
>                                       $result = $this->db->fetchAll($sql);
>                                       $accountInfo = $result[0];
>                                       /*
>                                        * Set The Date Format for dojo Must be 
> in format YYYY-MM-DD
>                                       */
>                                       $birthday = explode('-', 
> $accountInfo['birthday']);
>                                       $birthday[2] = substr($birthday2, 0, 2);
>                                       $birthdayTimestamp = mktime(null, null, 
> null, $birthday[1],
> $birthday[2], $birthday[0]);
>                                       $accountInfo['birthday'] = 
> date('Y-m-d', $birthdayTimestamp);
>                               }
> 
> 
>                               // Send the users Picture to the view
>                               $this->view->picture = $accountInfo['image'];
> 
>                               // Render the form
>                               $this->view->adminContent =
> $this->admin->renderForm('producerEditLeft', 'producerEditRight',
> $this->form, 'users/producer', $accountInfo, $accountInfo);
>                       }
>                       elseif ( ( null != $this->userGroupId && 
> $this->userGroupId ==
> CORPORATE_SPONSOR ) || $this->user->getLevel() == CORPORATE_SPONSOR )
>                       {
>                               echo 'Master Admin Editing Sponsor';
>                       }
>                       elseif ( ( null != $this->userGroupId && 
> $this->userGroupId ==
> PUBLISHER ) || $this->user->getLevel() == PUBLISHER )
>                       {
>                               echo 'Master Admin Editing Publisher';
>                       }
>                       elseif ( ( null != $this->userGroupId && 
> $this->userGroupId ==
> CONTENT_ADMIN ) || $this->user->getLevel() == CONTENT_ADMIN )
>                       {
> 
>                       }
>                       elseif ( ( null != $this->userGroupId && 
> $this->userGroupId == USERS )
> || $this->user->getLevel() == USERS )
>                       {
> 
>                       }
>                       elseif ( !$this->isMaster )
>                       {
>                               throwException(PERM_MSG);
>                       }
>                       else
>                       {
>                               // Master Admin Account Information
>                       }
>               }
>               elseif($this->getRequest()->isPost())
>               {
>                       if ( $this->userGroupId == PRODUCER || 
> $this->user->getLevel() ==
> PRODUCER)
>                       {
>                               // User input will be proccessed using the 
> User_Auth getPost(); to
> validate and secure it
>                               $post = $this->user->getPost();
>                               if ($post['password'] != null)
>                               {
>                                       $salt = rand(1000, 9999);
>                                       $password = 
> sha1($post['password'].$salt);
>                                       $sql = 'UPDATE '.USER.' SET password = 
> "'.$password.'", salt =
> "'.$salt.'" WHERE userId = "'.$this->userId.'"';
>                                       $this->db->query($sql);
>                               }
> 
>                               $birthday = $post['birthday'] . ' 00:00:00';
> 
>                               $sql = '"
>                                               WHERE userId = 
> "'.$this->userId.'"';
>                               //$this->db->query($sql);
> 
>                               $sql = 'edited out';
>                               //$this->db->query($sql);
> 
>                               $this->admin->message('Account has been 
> updated');
> 
>                       }
>                       elseif ( $this->userGroupId == PUBLISHER || 
> $this->user->getLevel() ==
> PUBLISHER)
>                       {
>                               $sql = 'Publisher Update';
>                       }
>                       elseif ( $this->userGroupId == CORPORATE_SPONSOR ||
> $this->user->getLevel() == CORPORATE_SPONSOR)
>                       {
>                               $sql = 'SPonsor Update';
>                       }
>                       elseif ( $this->userGroupId == CONTENT_ADMIN || 
> $this->user->getLevel()
> == ADMIN)
>                       {
>                               $sql = 'Content Admin Update';
>                       }
>                       elseif ( $this->userGroupId == USERS || 
> $this->user->getLevel() ==
> USERS)
>                       {
>                               $sql = 'User Update';
>                       }
>                       else
>                       {
>                               $sql = 'Master Admin Update';
>                       }
>               }
> 
> 
> 

Also what im trying to do with this is put it in the _createElement method
so the error validation is parsed in automatically when the elements are
created

-----
Nickolas Whiting 

Developer 

http://xstudiosinc.com Xstudios 
-- 
View this message in context: 
http://www.nabble.com/Zend-Form-Validation-tp20267185p20304951.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to