Adding force preview to node and changing value of submit button in Drupal?
This question is twofold:
- Is there a way to force the user to preview a SPECIFIC node before submitting? i.e. not all nodes using / admin / content / node-settings ... but only ONE specific node.
- Is there a way to change the shortcuts instead of saying "submit" and "preview" rather say "Process" and "Review"?
source to share
The main answer to both questions is hook_form_alter()
. You will need to check the parameter $form_id
to determine if you are in an edit node form (they get an id [contenttype]_node_form
, see the first line of the implementation example on the API docs page for a launching method for all content types).
For your need 1, you would check $node->nid
to determine if this is your specific node. If so, you would change the "#access" submission form definition elements to disable it if you are not on the preview page (see node_form()
the node module for how Drupal does this - pretty far from the end of the function).
For your need 2, you just change the "#value" entries in the submit and preview button definition in the $ form array.
source to share