I have been trying to create a Flag using a YAML file with information taken from the Patterns Form Helper & Drupal for Firebug. I've tried everything I could think of, but I'm at a loss.
Any help will be greatly appreciated.
info:
title: Flag module setup (YAML)
description: Setup options for Flag module
author: Christopher Gervais
author_email: ergonlogic@gmail.com
category: Module Configuration
modules:
- flag
- flag_actions
actions:
- tag: form
form_id: flag_form
name: test_flag1
title: Test Title
flag_short: Flag Text
unflag_short: Unflag Text
types:
0: page
args:
- add/node/test_flag1
The error occurs when the progress bar flashes "Initializing", but doesn't look like a normal Patterns error. Rather than reporting the error on the Patterns page, with some helpful notes, it results in an error on the Processing page, and dumps the HTML of the flag form:
Processing pattern Flag module setup (YAML)
An error has occurred.
Please continue to the error pageAn error occurred. /batch?id=46&op=do <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" /> <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/admin_menu/admin_menu.css?r" /> <link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?r" /> <link type="text/css" rel="stylesheet"....
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | flag-6--2_fix_submit.patch | 764 bytes | ergonlogic |
| #6 | flag-6--1_fix_submit.patch | 753 bytes | ergonlogic |
Comments
Comment #1
ergonlogicAlso, when I click the "error page" link, I am returned to the Patterns page, where the usual "Pattern ran successfully" message appears, and the status shows as "Enabled".
Which seems odd.
Comment #2
vaish commentedFlag module is not compatible with the way how patterns work because it's using drupal_goto() instead of $form['redirect] in flag_add_form_submit(). That's causing HTML dump you've described in your issue above. I'm putting this issue under flag project in case module's author is interested to update the submit function.
Besides that, your pattern needs some adjustments as well. This is how the pattern action should look finally:
Comment #3
quicksketchWeird, I wouldn't think we'd be using drupal_goto() in a submit handler. If we are, I think it qualifies as a bug.
Comment #4
ergonlogicSo this should use form_state['redirect'] then, as per http://drupal.org/node/310513 and http://api.drupal.org/api/drupal/developer--topics--forms_api.html/6, correct?
Comment #5
quicksketchYes that's right.
Comment #6
ergonlogicSo, that seems simple enough:
I've attached patches against the CVS versions of the two 6.x branches.
It appears to work just fine, though I haven't yet tested it in the use case that initiated this thread, i.e. creating flags with Patterns.
Comment #7
ergonlogicI have now tested the 6--2 patch with the Patterns module, as per the original use case, with pattern actions defined as per #2. It worked without a hitch. Assuming the patches pass muster, I'd say this bug report can be closed.
@Vaish: Thanks for the help with the pattern. I must have tried 20 variations on passing arguments without success. Of course, in retrospect, even had I hit on the proper format, with the bug in flag.module, I never would have known...
Comment #8
quicksketchLooks good to me, I'll add it in next time I'm working on Flag.
Comment #9
quicksketchCommitted ergonlogic's #6 to both branches. Thanks!