[horde] Horde_Form_Action_conditional_enable

Chuck Hagenbuch chuck at horde.org
Tue Jul 5 18:40:21 PDT 2005


Quoting "Liebe Markus (AE/BA-S) *" <Markus.Liebe at de.bosch.com>:

> I am trying to find information on the usage of 
> Horde_Form_Action_conditional_enable. I want to enable or disable an 
> element on a form based on the value of another element.
> As I did not find an example on this (I had a look at 
> /hordedoc/developer/* and the various Horde Applications as well as 
> the api) I wanted to ask, if anyone of you can point me to somwhere 
> where I can find more information on how to use 
> Horde_Form_Action_conditional_enable. Is there a Horde application 
> that uses this class?

Looks like no. But this should help:

<?php
/**
* Example for the conditional_enable action.
*/

@define('HORDE_BASE', dirname(__FILE__));
require_once HORDE_BASE . '/lib/core.php';
require_once 'Horde/Form.php';
require_once 'Horde/Form/Action.php';
require_once 'Horde/Form/Renderer.php';
require_once 'Horde/Variables.php';

$registry = &Registry::singleton();

$vars = &Variables::getDefaultVariables();
$form = &Horde_Form::singleton('', $vars, 'Using conditional enable');

$params = array('target' => 'choices',
                'enabled' => true,
                'values' => array('other'));
$action = &Horde_Form_Action::singleton('conditional_enable', $params);

$choices = array('big' => 'BIG',
                 'small' => 'small',
                 'other' => 'Other');
$form->addVariable('Select something', 'choices', 'enum', true, false, 
'', array($choices, true));
$o = &$form->addVariable('If other, please describe', 'other_text', 
'text', false, false);
$o->setAction($action);

/* Render the form. */
$renderer = &new Horde_Form_Renderer();
$form->renderActive($renderer, $vars, 'form.php', 'post');

-chuck

-- 
"But she goes not abroad in search of monsters to destroy." - John 
Quincy Adams


More information about the horde mailing list