Error message

  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

protected function JobItemForm::buildTranslation

Builds the translation form element for a data item.

Parameters

array $item_element: The form element for the data item.

string $translation_text: The translation's text to display in the item element.

array $data_item: The data item.

int $rows: The number of rows that should be displayed.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

bool $is_preliminary: TRUE is the data item is in the PRELIMINARY STATE, FALSE otherwise.

Return value

array The form element for the data item.

1 call to JobItemForm::buildTranslation()
JobItemForm::reviewFormElement in src/Form/JobItemForm.php
Build form elements for the review form using flattened data items.

File

src/Form/JobItemForm.php, line 989

Class

JobItemForm
Form controller for the job item edit forms.

Namespace

Drupal\tmgmt\Form

Code

protected function buildTranslation($item_element, $translation_text, $data_item, $rows, FormStateInterface $form_state, $is_preliminary) {
  if (isset($data_item['#file'])) {
    $item_element['translation'] = array(
      '#type' => 'managed_file',
      '#default_value' => !empty($data_item['#translation']['#file']) ? [
        $data_item['#translation']['#file'],
      ] : NULL,
      '#title' => t('Translation'),
    );
  }
  elseif (!empty($data_item['#format']) && $this
    ->config('tmgmt.settings')
    ->get('respect_text_format') && !$form_state
    ->has('accept_item')) {
    $item_element['translation'] = array(
      '#type' => 'text_format',
      '#default_value' => $translation_text,
      '#title' => t('Translation'),
      '#disabled' => $this->entity
        ->isAccepted() || $is_preliminary,
      '#rows' => $rows,
      '#allowed_formats' => array(
        $data_item['#format'],
      ),
    );
  }
  elseif ($form_state
    ->has('accept_item')) {
    $item_element['translation'] = array(
      '#type' => 'textarea',
      '#title' => t('Translation'),
      '#value' => t('This field has been disabled because you do not have sufficient permissions to edit it. It is not possible to review or accept this job item.'),
      '#disabled' => TRUE,
      '#rows' => $rows,
    );
  }
  else {
    $item_element['translation'] = array(
      '#type' => 'textarea',
      '#default_value' => $translation_text,
      '#title' => t('Translation'),
      '#disabled' => $this->entity
        ->isAccepted() || $is_preliminary,
      '#rows' => $rows,
    );
    if (!empty($data_item['#max_length'])) {
      $item_element['translation']['#max_length'] = $data_item['#max_length'];
      $item_element['translation']['#element_validate'] = [
        '::validateMaxLength',
      ];
    }
  }
  if (!empty($data_item['#translation']['#text_revisions'])) {
    $revisions = array();
    foreach ($data_item['#translation']['#text_revisions'] as $revision) {
      $revisions[] = t('Origin: %origin, Created: %created<br />%text', array(
        '%origin' => $revision['#origin'],
        '%created' => $this->dateFormatter
          ->format($revision['#timestamp']),
        '%text' => Xss::filter($revision['#text']),
      ));
    }
    $item_element['below']['revisions_wrapper'] = array(
      '#type' => 'details',
      '#title' => t('Translation revisions'),
      '#open' => TRUE,
    );
    $item_element['below']['revisions_wrapper']['revisions'] = array(
      '#theme' => 'item_list',
      '#items' => $revisions,
    );
  }
  return $item_element;
}