0

I have created a composite element where I added a custom textarea field in the element settings.

I have added that element in a webform, filled that textarea and saved the webform.

Now I want to translate the webform, But when I go the webform translations, I am unable to translate the value of that text area.

Is there any way to translate the value of that text area?

/**
 * Provides a booking element.
 *
 * @WebformElement(
 *   id = "my_element",
 *   label = @Translation("My element"),
 *   category = @Translation("Composite elements"),
 *   multiline = TRUE,
 *   composite = TRUE,
 *   states_wrapper = TRUE,
 * )
 */
class Myelement extends WebformCompositeBase {
  public function form(array $form, FormStateInterface $form_state): array {
    $form = parent::form($form, $form_state);

    $form['element']['booking_email'] = [
      '#type' => 'textarea',
      '#title' => $this->t('some content'),
      '#weight' => '0',
    ];

    return $form;
  }
}

Here is the backend of the element settings. enter image description here

And here is the webform translation interface. I can't see my textarea field so that I can translate its content. I only see the composite element key and title. enter image description here

0

You need to create a schema config file to make them translatable.

I have done it like this by creating my_module.plugin.handler.schema.yml file in my my_module/config/schema directory.

webform.handler.my_element:
  type: mapping
  label: Booking email
  mapping:
    booking_email:
      label: 'Something'
      type: text
  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.