Edit an existing case
To edit an existing case, you will need the reference for the case you want to edit and (optionally) the name of the CaseType for that case.
- Fetch the
CaseFormfor editing a case of that type - Update the values for each form field
- Submit the values
Fetching the edit form
Use the CaseManager to retrieve the edit form.
Fetch by case reference:
<?php
$caseReference = 'REF123456'; // Reference of an existing case
/** @var \Jadu\Quantum\ServiceApiClient\Manager\CaseManager $caseManager */
$caseManager = $container->get('quantum_service_api_client.manager.case');
$editForm = $caseManager->getEditForm($caseReference);
Fetch by CaseType name:
<?php
$caseTypeName = 'complaint'; // Name of CaseType for case that you want to edit
/** @var \Jadu\Quantum\ServiceApiClient\Manager\CaseManager $caseManager */
$caseManager = $container->get('quantum_service_api_client.manager.case');
$editForm = $caseManager->getEditForm(null, $caseTypeName);
Using the information in the CaseForm that is returned, you can now build up an array of values be updated on your case. Each CaseFormField has a unique name, you should use these as the key to each entry in the values array.
More information about CaseForms
<?php
$caseReference = 'REF123456';
$editForm = $caseManager->getEditForm($caseReference);
$values = [];
foreach ($editForm->getFields() as $formField) {
$values[$formField->getName()] = 'VALUE';
}
For example, given the following set of CaseFormFields:
| Name | Type |
|---|---|
| address | CaseAddressRelationshipField |
| website | CaseFieldField.UrlField |
| comments | CaseFieldField.TextareaField |
The following array might be created:
<?php
$values = [
'address' => 'AKMKWyo',
'website' => 'http://www.jadu.net/',
'comments' => 'Everything / Possible',
];
Once you have your values array, you can update the case:
<?php
$caseReference = 'REF123456';
$caseTypeName = 'complaint';
$case = $caseManager->save($caseForm, $values, $caseReference, $caseTypeName);