Documentation
IPS_UpdateFormField
bool IPS_UpdateFormField (string $Field, string $Parameter, mixed $Value, string $SessionID)
Parameters
| Field | Name of the form field to be changed |
| Parameter | Name of the parameter to be changed |
| Value | New value of the parameter |
| SessionID | SessionID of the open action form |
Returns
If the function is executed successfully, it returns TRUE, otherwise FALSE.
Description
Sets the parameter Parameter of the form field named Field in the open form of an action to the value Value. The form is identified by the SessionID. Within the form fields of an action, e.g. in "onChange", the SessionID is available in the variable $id.
The function is the counterpart of the module function UpdateFormField ($this->UpdateFormField), which changes form fields in the open configuration forms of an instance. As the form of an action does not belong to an instance, it is addressed via the SessionID instead.
The change is sent as a message to the connected clients, e.g. the console. It is not checked whether a form with this SessionID is open or whether the form field exists. In this case the call has no effect, the function still returns TRUE.
It is not possible to change the parameters name and type of form fields. Other parameters that cannot be changed are listed in the respective documentation.
Only Boolean, Integer, Float and String are possible as Value. For complex parameters, i.e. lists or objects, the new value must be passed JSON-encoded.
Example
// Dynamic form of an action (entry "form"): If another status variable is selected,
// the target of the field "ACTION" is adjusted in the open action form. $id contains the SessionID
return [
[
'type' => 'Select',
'name' => 'IDENT',
'caption' => 'Status Variable',
'options' => $options,
'onChange' => 'IPS_UpdateFormField("ACTION", "targetID", IPS_GetObjectIDByIdent($IDENT, ' . $_IPS['TARGET'] . '), $id);'
],
[
'type' => 'SelectAction',
'name' => 'ACTION',
'caption' => 'Action'
]
];