From 69213908362ffd7cc0bf7a2cb3bec368a3706fa8 Tue, 9 Aug 2011 20:34:34 +0200 From: Bram Goffings Date: Tue, 9 Aug 2011 20:34:28 +0200 Subject: [PATCH] Form #primary diff --git a/includes/form.inc b/includes/form.inc index 40363d6..7f42294 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1918,6 +1918,11 @@ } } + // I don't now if this is the correct place for this + if (!empty($element['#primary'])) { + $element['#attributes']['primary'] = 'primary'; + } + // With JavaScript or other easy hacking, input can be submitted even for // elements with #access=FALSE or #disabled=TRUE. For security, these must // not be processed. Forms that set #disabled=TRUE on an element do not @@ -3593,6 +3598,9 @@ if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } + if (!empty($element['#attributes']['primary'])) { + $element['#attributes']['class'][] = 'form-button-primary'; + } return ''; } @@ -3621,6 +3629,9 @@ $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; + } + if (!empty($element['#attributes']['primary'])) { + $element['#attributes']['class'][] = 'form-button-primary'; } return ''; @@ -3801,6 +3812,7 @@ * - form-item-#name: The internal form element #name (usually derived from the * $form structure and set via form_builder()). * - form-disabled: Only set if the form element is #disabled. + * - form-primary: Only set if this is the primary form element. * * In addition to the element itself, the DIV contains a label for the element * based on the optional #title_display property, and an optional #description. @@ -3864,6 +3876,10 @@ if (!empty($element['#attributes']['disabled'])) { $attributes['class'][] = 'form-disabled'; } + // Add a class for primary a primary form element. + if (!empty($element['#attributes']['primary'])) { + $attributes['class'][] = 'form-primary'; + } $output = '' . "\n"; // If #title is not set, we don't display any label or required marker. diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index d92e8b7..111867a 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -270,6 +270,7 @@ '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])), '#value' => t('Save'), '#weight' => 5, + '#primary' => TRUE, '#submit' => array('node_form_submit'), ); $form['actions']['preview'] = array(