Re: Actions based on rules

From: Date: Mon, 29 Oct 2007 18:14:16 +0000
Subject: Re: Actions based on rules
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28142@lists.php.net to get a copy of this message
I am using this: $this->addRule('url', _('Enter a web address'), 'required'); if (!$this->addFormRule(array($this,'urlExists'))) {
       $this->tpl->assign('checkbox',true);
       $this->addElement('checkbox','continue',_('Continue anyway'));
} function urlExists($fields) {
     if(page_exists($fields['url'])) {
       return true;
     } else {
       return array('url' => _('URL not responding'));
    }
} but if i do not type any url I only want to show the "enter a web address" message but I am also geting the addFormRule rules and the checkbox is show, what i do for solving this is to use somethiing like: if ($this->validate() && !empty($_POST['url'])) { $this->tpl->assign('checkbox',true);
     $this->addElement('checkbox','continue',_('Continue anyway'));
} but would like to know if there is a better method . regards. On Oct 29, 2007, at 6:40 AM, Mark Steudel wrote:
Hi there I'm just trying to understand, in this case he'd have to move the individual validation from any of the form elements into one addFormRule validation function, is that what you are saying? Mark -----Original Message----- From: Bertrand Mansion [mailto:golgote@mamasam.com] Sent: Monday, October 29, 2007 11:12 AM To: Nicolas de Bari Embriz Garcia Rojas Cc: PEAR general list Subject: Re: [PEAR] Actions based on rules Le 29 oct. 07 à 06:36, Nicolas de Bari Embriz Garcia Rojas a écrit :
Hi all, I am using html_quickform for requesting url and tile but i would like to display a check box (continue anyway) if one of the rules (not a valid url) do not pass, at the moment i am doing this: if ($this->validate() && !empty($_POST['url'])) {
      $this->tpl->assign('checkbox',true);
      $this->addElement('checkbox','continue',_('Continue anyway'));
} Is there a way to get the output or the registerRules so later based on that output do some actions?
For this, I'd suggest you use addFormRule() and let the form go if the checkbox is checked. --PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.pear.general (#28142) next »