If there are elements with validate function and I press cancel button, then I obtain form back, with validating error message (no required values or something else).
But I expect execute cancel callback and redirect to 'cancel path'.

What about making some changing in ctools_validate_form function?
Something like:

function ctools_validate_form($form_id, $form, &$form_state) {
  static $validated_forms = array();

  if (!empty($form_state['cancel_validate']) || (isset($validated_forms[$form_id]) && empty($form_state['must_validate']))) {
    return;
  }

and #process or #after_build function on $form['buttons']['cancel'], where we set $form_state['cancel_validate'], when cancel button is clicked.

The task is somehow corrupt validating form with _form_validate($form, $form_state, $form_id) and going to execute cancel callback.

Thanx for that, if it is possible.

CommentFileSizeAuthor
#2 ctools.wizard.patch1.73 KBpokurek

Comments

merlinofchaos’s picture

If there are validates on specific elements, the button cannot force them not to run, unfortunately. I may have to play with this a little, but at the moment I believe this is a deficiency of FAPI and I can't do anything about it.

pokurek’s picture

StatusFileSize
new1.73 KB

Hi merlin,
This patch works for me.
I don't know, If it is general, but for this purpose, it is enough I mean ;o)
Thanx for your great work.

Nick Lewis’s picture

Status: Active » Needs review

Looks promising.

pokurek’s picture

What do you think about using #process callback. It is executed soon after $form_state['clicked_button'] is defined in _form_builder_handle_input_element(). But #process callback mean something else, than It is using in this case.
Maybe #after_build ($form, $form_state) will be a better solution.

merlinofchaos’s picture

Hm. Interesting.

The problem is that CTools form stuff is now in core in D7, and it does not contain this method to cancel. And it is probably too late to put such a method into D7. Which means that this will nto be portable moving to D7, which is a problem.

pokurek’s picture

OK, I see,

perhaps this problem could be solved by using this module http://drupal.org/project/skip_validation.

Thanx and have a nice time.

merlinofchaos’s picture

Status: Needs review » Closed (won't fix)

Moving to won't fix since it's not going to make it in due to reasons stated in #5.