0

I created the node type 'application',which can be added by any users and will be unpublished by default. I used hook_form_id_alter() to change the text of the submit button as below:

 function custom_module_form_node_application_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { 


         //   to change the text of the button
          if (isset($form['actions']['publish'])) {
            unset($form['actions']['publish']);
          } 
       if(isset($form['actions']['unpublish'])) {
           $form['actions']['unpublish']['#value'] = 'Apply';
       }
}

It is updating the button text,only when I logged in as admin, but for anonymous users and others submit button text is 'Save' instead of 'Apply'.

  • Just a guess, maybe an anonymous user has no permission to publish and therefore the two actions buttons publish/unpublish are not present. – 4k4 Feb 8 '17 at 10:38
  • yes.He don't have permission to publish.. I'll check other $form['actions'] path – rks Feb 9 '17 at 6:33

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.