--- /dev/null
+<?php
+
+/**
+ * @file
+ * Helper module for the Content Translation tests.
+ */
+
+use \Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Implements hook_form_BASE_FORM_ID_alter().
+ *
+ * Adds a textfield to node forms based on a request parameter.
+ */
+function content_translation_test_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
+ $langcode = $form_state->getFormObject()->getFormLangcode($form_state);
+ if (in_array($langcode, ['en', 'fr']) && \Drupal::request()->get('test_field_only_en_fr')) {
+ $form['test_field_only_en_fr'] = [
+ '#type' => 'textfield',
+ '#title' => 'Field only available on the english and french form',
+ ];
+
+ foreach (array_keys($form['actions']) as $action) {
+ if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
+ $form['actions'][$action]['#submit'][] = 'content_translation_test_form_node_form_submit';
+ }
+ }
+ }
+}
+
+/**
+ * Form submission handler for custom field added based on a request parameter.
+ *
+ * @see content_translation_test_form_node_article_form_alter()
+ */
+function content_translation_test_form_node_form_submit($form, FormStateInterface $form_state) {
+ \Drupal::state()->set('test_field_only_en_fr', $form_state->getValue('test_field_only_en_fr'));
+}