I have develop a display-plugin and I would like to save some custom options. not in the view object but rather in a custom table from my DB.

Actually I use the option_submit() method to save these options but it isn't good cause the save is performed on the submit of the option form, not on the save of the view wich lead to inconsistency (the user cancel his modification in the view but in my custom table those chage are preserved,....).

Thanks for any advice.

Comments

dawehner’s picture

I'm quite sure that there is a issue about this topic already, but i can't find this issue. It should be in the queue.
This added a new hook

There is no hook beside using form-api at the moment.

dimiduj’s picture

Thanks for your support,

I'm sorry but I don't find the issue you are talking about...

I was wondering if there are reasons (performance issues, ...) to not implement such hooks ?

Finally, I 've skip the problem using a form_alter:
no hooks needed anymore on the save.
Is this solution correct ?

function mymodule_form_alter(&$form, &$form_state, $form_id){
  if($form_id=='views_ui_edit_view_form'){
    $form['buttons']['save']["#submit"]=array_merge(array('mymodule_save_views_layout'),$form['buttons']['save']["#submit"]);    
  }
}

function mymodule_save_views_layout($form,$form_state){
  //Do what I need
}
dawehner’s picture

The reason is easy: noone wrote a patch yet/we cannot find the patch/issue anymore :)

iamjon’s picture

dimiduj,

did you ever find a solution?

I spoke to merlinofchaos about this on irc, for creating the general hook he said


It's problematic because it doesn't help you with exports.
So it's not as easy as just making a hook.

did you ever find a solution using form alter?

please update.

bojanz’s picture

dimiduj’s picture

The solution describe in #2 works for me.

But I need to programaticaly saved my views when I use them with features (As Earl says, this technique cause troubles on export...).

I hope this could help you.

Letharion’s picture

Status: Active » Fixed

Temporary workaround provided, link to issue with a patch in #5.
Closing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.