Home > Archive > PHP Pear > October 2007 > Re: [PEAR] Actions based on rules
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] Actions based on rules
|
|
| Bertrand Mansion 2007-10-29, 8:03 am |
|
Le 29 oct. 07 =E0 06:36, Nicolas de Bari Embriz Garcia Rojas a =E9crit :
> Hi all, I am using html_quickform for requesting url and tile but =20
> i would like to display a check box (continue anyway) if one of the =20=
> 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',_('Cont
inue anyway'));
> }
>
> Is there a way to get the output or the registerRules so later =20
> based on that output do some actions?
For this, I'd suggest you use addFormRule() and let the form go if =20
the checkbox is checked.=
| |
| Mark Steudel 2007-10-29, 7:04 pm |
| 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]=20
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 =E0 06:36, Nicolas de Bari Embriz Garcia Rojas a =E9crit :
> Hi all, I am using html_quickform for requesting url and tile but =20
> i would like to display a check box (continue anyway) if one of the =20
> 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',_('Cont
inue anyway'));
> }
>
> Is there a way to get the output or the registerRules so later =20
> based on that output do some actions?
For this, I'd suggest you use addFormRule() and let the form go if =20
the checkbox is checked.
--=20
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
| |
| Nicolas de Bari Embriz Garcia Rojas 2007-10-29, 7:04 pm |
| 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',_('Cont
inue 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',_('Cont
inue 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 :
>
>
> 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
>
|
|
|
|
|