Conditional Controls

C
onditional controls are controls which output something if some condition is true. This condition is evaluated right before the output is generated, so it is "dynamic".

Instead of having controls which output a textfield if some condition is true, and another control which outputs a textarea if some condition is true... one abstracts it one level. These conditional controls typically take other controls (called sub-controls) as parameters (as part of the constructor) and activate the sub-controls when the condition is satisfied. So a conditional control, when asked to generate the output, evaluates the condition and if the condition evaluated to true, asks the sub-controls to generate their output and gives that as its output.

Some examples include:

  • IfModeControl: takes two sets of sub-controls, and a set of modes as inputs. If the current mode belongs to the given set of modes, it activates one set of sub-controls, and otherwise activates the other set.

  • IfFieldControl: activates one set of controls if some particular field value (given in the constructor) evaluated by the query underlying the page is non-empty, otherwise activates the other set.

  • IfThenElseControl: the grand daddy of all conditional controls. Defines two methods condition_disp and condition_form (which has to be over ridden by any descendant) and activates one of four possible sets of controls depending on the current shape and whether the corresponding condition evaluated to reu or not.