Form State
Commands that control the form's state — reloading, saving records, managing GUIDs, and server-side validation.
RedrawScreen
Force the form to refresh and redraw.
When to use: After data changes that require the entire form to reload.
JSON Response:
{
"feCommand": {
"RedrawScreen": true
}
}
- C# / .NET
- PHP
if (string.Equals(widgetName, "REFRESHBTN"))
{
request.FormData["fieldName"] = "updatedValue";
response.Set("FECommand", new Dictionary<string, object>
{
["RedrawScreen"] = true
});
}
response.Set(HandlerResponse.FormData, request.FormData);
if ($widgetName === 'REFRESHBTN') {
$formData = $request->all();
$formData['fieldName'] = 'updatedValue';
$response['feCommand']['RedrawScreen'] = true;
}
$response['data'] = $request->all();
Parameters:
- (boolean) -
trueto redraw,falseto skip
AfterRecordSave
Close a modal form and refresh the parent form after a successful save.
When to use: After saving a record inside a modal — closes the modal and passes the new GUID back to the parent.
JSON Response:
{
"feCommand": {
"AfterRecordSave": {
"guid": "550e8400-e29b-41d4-a716-446655440000"
},
"RedrawScreen": true
}
}
- C# / .NET
- PHP
if (string.Equals(widgetName, "SAVEBTN"))
{
string newRecordGuid = SaveRecordToDatabase(request.FormData);
response.Set("FECommand", new Dictionary<string, object>
{
["AfterRecordSave"] = new { guid = newRecordGuid },
["RedrawScreen"] = true
});
}
response.Set(HandlerResponse.FormData, request.FormData);
if ($widgetName === 'SAVEBTN') {
$newRecordGuid = $this->saveRecordToDatabase($request->all());
$response['feCommand']['AfterRecordSave'] = ['guid' => $newRecordGuid];
$response['feCommand']['RedrawScreen'] = true;
}
$response['data'] = $request->all();
Parameters:
guid(string) - New record GUID to pass to the parent form
This command is typically paired with RedrawScreen: true to refresh the parent form after the modal closes.
ReplaceContextRecordGuid
Replace the current record GUID in the form context.
When to use: After creating a new record, update the form URL/context to reflect the new GUID instead of "new".
JSON Response:
{
"feCommand": {
"ReplaceContextRecordGuid": {
"guid": "550e8400-e29b-41d4-a716-446655440000"
}
}
}
- C# / .NET
- PHP
if (string.Equals(widgetName, "CREATENEWBTN") && request.Guid == "new")
{
string newRecordGuid = Guid.NewGuid().ToString();
response.Set("FECommand", new Dictionary<string, object>
{
["ReplaceContextRecordGuid"] = new { guid = newRecordGuid }
});
}
if ($widgetName === 'CREATENEWBTN' && $request->input('guid') === 'new') {
$newRecordGuid = uniqid('', true);
$response['feCommand']['ReplaceContextRecordGuid'] = ['guid' => $newRecordGuid];
}
Parameters:
guid(string) - New record GUID to use
FormValidationData
Display validation errors on specific form fields.
When to use: Server-side validation that needs to highlight fields with error messages.
JSON Response:
{
"feCommand": {
"FormValidationData": {
"email": "Invalid email format",
"phone": "Phone number is required",
"customerName": "Name must be at least 3 characters"
}
}
}
- C# / .NET
- PHP
if (string.Equals(widgetName, "SUBMITBTN"))
{
var validationErrors = new Dictionary<string, string>();
if (string.IsNullOrEmpty(request.FormData["email"] as string))
validationErrors["email"] = "Invalid email format";
if (string.IsNullOrEmpty(request.FormData["phone"] as string))
validationErrors["phone"] = "Phone number is required";
if (request.FormData.TryGetValue("customerName", out var name) && (name as string)?.Length < 3)
validationErrors["customerName"] = "Name must be at least 3 characters";
if (validationErrors.Count > 0)
{
response.Set("FECommand", new Dictionary<string, object>
{
["FormValidationData"] = validationErrors
});
}
}
if ($widgetName === 'SUBMITBTN') {
$validationErrors = [];
$formData = $request->all();
if (empty($formData['email']))
$validationErrors['email'] = 'Invalid email format';
if (empty($formData['phone']))
$validationErrors['phone'] = 'Phone number is required';
if (isset($formData['customerName']) && strlen($formData['customerName']) < 3)
$validationErrors['customerName'] = 'Name must be at least 3 characters';
if (!empty($validationErrors))
$response['feCommand']['FormValidationData'] = $validationErrors;
}
Parameters:
- (object) - Key/value map of field names to error message strings
FormValidationData clears all other commands. Validation errors stop all other form actions.