[dev] Question to Horde Form Actions

Jan Schneider jan at horde.org
Mon Jul 9 13:17:25 UTC 2012


Zitat von Karim Geiger <geiger at b1-systems.de>:

> Hi *,
>
> we're currently trying to get a Horde Form Action working.. here is the
> current code we wrote so far:
>
> class B1training_Form_Add extends Horde_Form {
>
>     /**
>      * Basic constructor for the SearchForm.
>      *
>      * @param  Horde_Variables $vars  The default variables to use.
>      */
>     function __construct($vars)
>     {
>         parent::__construct($vars, _("Add a training"));
>
>         $this->appendButtons(_("Add"));
>
> [...]
>
>         $this->addVariable(_("Mobile classroom"),
>                            'training_needclassroom', 'enum', true,
>                            false, _("Do we need a mobile classroom?"),
>                            array(array(1 => _('yes'), 0 => _('no')),
>                            true));
>
>
>         // This one is not working. Expected behavior:
>         // If training_needclassroom = 1 then show training_sub
>         //
>         // Current behavior:
>         // training_sub is always visible, no matter what value is set
>         // on training_needclassroom
>
>         $o = $this->addVariable(_("Sub-Item"), 'training_sub', 'text',
> false);
>         $params = array('target' => 'training_needclassroom',
>                         'enabled' => true,
>                         'values' => array(1));
>         $o->setAction(new Horde_Form_Action_ConditionalEnable($params));
>
>     }
>
> }
>
> I'd appreciate your help ;)

You need to attach an action to the training_classroom variable  
instead, because this is the field that should trigger the action  
(disabling the second field).
And you might want to use the reload action instead, so that you can  
completely ignore the other field if necessary.
-- 
Jan Schneider
The Horde Project
http://www.horde.org/



More information about the dev mailing list