[horde] Horde_Form_Action_conditional_enable

Liebe Markus (AE/BA-S) * Markus.Liebe at de.bosch.com
Tue Aug 2 05:08:20 PDT 2005


Hi!
Thanks for the example Chuck! (code: see bottom of the message)
I had not enough time during the last weeks to test it. Today I did. 
The Form that your example creates is shown, but I can't see the form
disabling/enabling the inputbox "other_text" based on the value of the
inputbox "choices".
I am no JavaScript coder, but I noticed that firefox prints the
following message on its javascript console:
Error: last has no properties
(form_helpers.js Line 40)

I tested the form with firefox 1.0 and IE 6.0 (6.0.2800.1106CO)

I thought, that by using this class I would be able to enable or disable
input elements on a given form, so that they are locked or free for
input depending on the value of another element on the form. Is that
assumption correct? 
If so, do you have an idea what I am doing wrong at the moment?

Markus
 
> > 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




More information about the horde mailing list