As now, "Save" button appears unconditionally when adding some form elements to a view and I agree it should be the default behavior. But here are some other use cases that don't require a Save button, i.e. if the form elements added to the view are #submit elements themselves.

Now the workaround is to unset or set #access to 0 via form_alter, but maybe it's a good idea not to display the button in some cases.

I've played a little with this adding a property to the form (in views_form of the handler i.e.) in order to set if the Save button should be built or not, but the risk of this is having a mix of non-submit elements and submit elements, then the Save button won't appear and it may be expected to.

Comments

merlinofchaos’s picture

Status: Active » Closed (works as designed)

See how the Theme: Information page does it. The button needs to be there, but that page changes the value so it doesn't say Save.

pcambra’s picture

Status: Closed (works as designed) » Active

Sorry to reopen this, but maybe I didn't explain myself good enough:

Just saying that if you add some submit elements to a view Save button shouldn't be there at all, because each field has its own submit button, for example:
https://skitch.com/pcambra/ggurt/orders-commerce-kickstart

(This is from Commerce Reorder module)

If you confirm it isn't enough reason for put some conditions to the general Save button, I'll hide it with a form alter which also works great.

frixos12’s picture

subscribing

vladimiraus’s picture

Version: 7.x-3.x-dev » 7.x-3.1

It is an issue for "Wight" module.
When view is empty, "Save" button is still there.
http://drupal.org/node/1432078

muhleder’s picture

It would be nice if we could alter the submit buttons in views handlers in $handler->views_form.

At the moment, the buttons are added right after our handlers get a chance to alter the form. If they were added before we could decide in our own handlers what whether we want a button or what it should say.

views.module#1789

  // Give the area handlers a chance to extend the form.
  $area_handlers = array_merge(array_values($view->header), array_values($view->footer));
  $empty = empty($view->result);
  foreach ($area_handlers as $area) {
    if (method_exists($area, 'views_form') && !$area->views_form_empty($empty)) {
      $area->views_form($form, $form_state);
    }
  }

  $form['#substitutions'] = array(
    '#type' => 'value',
    '#value' => $substitutions,
  );
  $form['actions'] = array(
    '#type' => 'container',
    '#attributes' => array('class' => array('form-actions')),
    '#weight' => 100,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );

  return $form;
michfuer’s picture

Subscribing.

aytee’s picture

Issue summary: View changes

The solution that I implemented was this:

1. Create a custom module with this hook_form_alter() function:

/**
* Implements hook_form_alter().
*/
function CUSTOM_MODULE_form_alter(&$form, &$form_state, $form_id){
  if($form_id == 'VIEWS_FORM_CUSTOM_FORM'){
  
	   $form['actions']['submit'] = array(
	      '#type' => 'submit',
	      '#value' => t('Add To Cart'),  //change your text here.  This was originally "Save"
	    );
  }
}

2. Install and Enable the Modules Weight module
3. In the Modules Weight configuration page, change the Weight of your CUSTOM_MODULE to be greater than Views so that your custom module hook_form_alter will fire after the Views.