function views_ui_standard_form_buttons
3.x admin.inc | views_ui_standard_form_buttons(&$form, &$form_state, $form_id, $name = NULL, $third = NULL, $submit = NULL) |
2.x admin.inc | views_ui_standard_form_buttons(&$form, &$form_state, $form_id, $name = NULL, $third = NULL, $submit = NULL) |
Provide standard buttons for the forms to make it easy. Also provide a hidden op operator because the forms plugin doesn't seem to properly provide which button was clicked.
10 calls to views_ui_standard_form_buttons()
- views_ui_add_item_form in includes/
admin.inc - Form to add_item items in the views UI.
- views_ui_analyze_view_form in includes/
admin.inc - Form constructor callback to display analysis information on a view
- views_ui_change_style_form in includes/
admin.inc - Form to change_style items in the views UI.
- views_ui_config_item_extra_form in includes/
admin.inc - Form to config_item items in the views UI.
- views_ui_config_item_form in includes/
admin.inc - Form to config_item items in the views UI.
File
Code
function views_ui_standard_form_buttons(&$form, &$form_state, $form_id, $name = NULL, $third = NULL, $submit = NULL) {
$form['buttons'] = array(
'#prefix' => '<div class="clear-block"><div class="form-buttons">',
'#suffix' => '</div></div>',
);
if (empty($name)) {
$name = t('Update');
}
// Add the override and update button
if ($name == t('Update default display')) {
$form['buttons']['override_update'] = array(
'#type' => 'submit',
'#value' => t('Update and override'),
'#submit' => array(
'views_ui_edit_display_form_override_update_section',
'views_ui_standard_submit',
'views_ui_edit_display_form_override_update',
),
);
}
if (empty($form_state['ok_button'])) {
// but be sure submit button validates!
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => $name,
'#submit' => array('views_ui_standard_submit', $form_id . '_submit'),
);
}
$cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : 'views_ui_standard_cancel';
$form['buttons']['cancel'] = array(
'#type' => 'submit',
'#value' => empty($form_state['ok_button']) ? t('Cancel') : t('Ok'),
'#submit' => array($cancel_submit),
'#validate' => array(),
);
if ($third) {
if (empty($submit)) {
$submit = 'third';
}
$third_submit = function_exists($form_id . '_' . $submit) ? $form_id . '_' . $submit : 'views_ui_standard_cancel';
$form['buttons'][$submit] = array(
'#type' => 'submit',
'#value' => $third,
'#validate' => array(),
'#submit' => array($third_submit),
);
}
// Compatibility, to be removed later:
// We used to set these items on the form, but now we want them on the $form_state:
if (isset($form['#title'])) {
$form_state['title'] = $form['#title'];
}
if (isset($form['#help_topic'])) {
$form_state['help_topic'] = $form['#help_topic'];
}
if (isset($form['#help_module'])) {
$form_state['help_module'] = $form['#help_module'];
}
if (isset($form['#url'])) {
$form_state['url'] = $form['#url'];
}
if (isset($form['#js'])) {
if (!empty($form_state['js settings']) && is_array($form_state['js settings'])) {
$form_state['js settings'] = array_merge($form_state['js settings'], $form['#js']);
}
else {
$form_state['js settings'] = $form['#js'];
}
}
if (isset($form['#section'])) {
$form_state['#section'] = $form['#section'];
}
// Finally, we never want these cached -- our object cache does that for us.
$form['#no_cache'] = TRUE;
// If this isn't an ajaxy form, then we want to set the title.
if (!empty($form['#title'])) {
drupal_set_title($form['#title']);
}
views_add_css('views-admin');
}