protected function LocalTaskItemForm::prepareData

Prepare the date to be added to the JobItem.

Right now JobItem looks for ['#text'] so if we send our structure it will add as translation text our original text, so we are replacing ['#text'] with ['#translation']['#text']

Parameters

array $data: The data items.

Return value

array Returns the data items ready to be added to the JobItem.

2 calls to LocalTaskItemForm::prepareData()
LocalTaskItemForm::preview in translators/tmgmt_local/src/Form/LocalTaskItemForm.php
Form submit callback for the preview button.
LocalTaskItemForm::saveAsComplete in translators/tmgmt_local/src/Form/LocalTaskItemForm.php
Form submit callback for save as completed submit action.

File

translators/tmgmt_local/src/Form/LocalTaskItemForm.php, line 447

Class

LocalTaskItemForm
Form controller for the localTaskItem edit forms.

Namespace

Drupal\tmgmt_local\Form

Code

protected function prepareData(array $data) {
  if (isset($data['#text'])) {
    if (isset($data['#translation']['#text'])) {
      $result['#text'] = $data['#translation']['#text'];
    }
    else {
      $result['#text'] = '';
    }
    return $result;
  }
  foreach (Element::children($data) as $key) {
    $data[$key] = $this
      ->prepareData($data[$key]);
  }
  return $data;
}