Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By apprentia on
Hello,
I need to change the text of the "Save" button of a node creation form of a certain content type (form is displayed in front-office). I tried this preprocess function :
function mytheme_my_content_type_form_alter(&$variables, &$form){
if ( isset($form['actions']['publish']) ) {
$form['actions']['publish']['#value'] = 'Submit';
}
}
I'm kinda stuck here...
Thanks for your help !
Comments
form alter
You can't do this in preprocess, and btw what you have above is an "alter" (albeit with incorrect parameters), so you're mostly on the right track.
I would use a strait form alter because for node forms there are two ID's, one for the add form and one for the edit form. You can study the form array by installing the Devel module and using the kint() function to print it all out nicely on the page.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21fo...
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.