You are here

protected function WebformContentCreatorManageFieldsForm::constructCustomValue in Webform Content Creator 3.x

1 call to WebformContentCreatorManageFieldsForm::constructCustomValue()
WebformContentCreatorManageFieldsForm::constructTable in src/Form/WebformContentCreatorManageFieldsForm.php
Constructs table with mapping between webform and content type.

File

src/Form/WebformContentCreatorManageFieldsForm.php, line 269

Class

WebformContentCreatorManageFieldsForm
Form handler for the Webform content creator manage fields form.

Namespace

Drupal\webform_content_creator\Form

Code

protected function constructCustomValue($field_id, array $attributes, $component_field = NULL) {
  if (!empty($component_field)) {
    $default_value = array_key_exists($field_id, $attributes) ? $attributes[$field_id][$component_field][self::CUSTOM_VALUE] : '';
  }
  else {
    $default_value = array_key_exists($field_id, $attributes) ? $attributes[$field_id][self::CUSTOM_VALUE] : '';
  }
  $custom_value = [
    '#type' => !empty($component_field) ? 'textfield' : 'textarea',
    '#title' => !empty($component_field) ? '(' . $component_field . ')' : NULL,
    '#default_value' => $default_value,
  ];
  return $custom_value;
}