I would like to submit an article in English but when I press submit button I would like to create its translation(s) as well. Can I do it with hook_form_alter?

I have this now:

 * Implements hook_form_alter().

function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {


  switch ($form_id) {

    case 'node_article_form':

      $form['actions']['unpublish']['#submit'][] = 'mymodule_node_article_form_submit';
      $form['actions']['publish']['#submit'][] = 'mymodule_node_article_form_submit';



function mymodule_node_article_form_submit($form, FormStateInterface $form_state) {
  drupal_set_message('Running custom submit handler...');

Your Answer

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

Browse other questions tagged or ask your own question.