When specifying more than one id under "Other form ID's" , the trick question shows up in only one of the forms or none at all. I assume the problem is the OS-dependant line-break "\n" (unix) which differs to the one in windows "\r\n".
simple solution that worked for me:
change line 210 from
$form_ids = explode("\n", variable_get('trick_question_form_ids', ''));
to
$form_ids = preg_split('~\R~', variable_get('trick_question_form_ids', ''));
// Get the custom forms
$ids = array();
$form_ids = preg_split('~\R~', variable_get('trick_question_form_ids', ''));
if (is_array($form_ids)) {
foreach ($form_ids as $id) {
if (trim($id)) {
$ids[$id] = $id;
}
}
}| Comment | File | Size | Author |
|---|---|---|---|
| #4 | trick_question-formids-carriage-return-fix-1421148-4.patch | 2.59 KB | Antti J. Salminen |
Comments
Comment #1
vertikal.dk commentedmatze85,
Thanks for the heads up and the tip. I know of the Windows/Unix line break issue, but even though I have developed the module on a Windows server I never saw this problem.
I didn't know of the ~\R~ argument for regular expressions either, but then on the other hand, regular expressions is kinda woodoo to me anyway, and I only know the most essential constructions.
I will incorporate your way of doing it in the next installment of the module.
Martin
Comment #2
Tech-2 commentedHi,
I have also run across this issue. The fix by matze85 worked for me, too, but I do want to note that I'm on a linux server. I also found and uncommented the return statement that was skipped, forcing the users assigned to roles that could skip the trick question to fill it out.
Comment #3
HumanTex commentedI couldn't quickly verify that Drupal's parser can interpret the \R variant, and the tilde character [~] doesn't appear in any documentation I could find as parse-able, but I did run across another regex 'catchall' expression that should work for any platform - plus - Unicode/UTF, making it universal...
(?>\r\n|\n|\x0b|\f|\r|\x85|\x2028|\x2029)makes the line read as:$form_ids = explode("(?>\r\n|\n|\x0b|\f|\r|\x85|\x2028|\x2029)", variable_get('trick_question_form_ids', ''));From: http://stackoverflow.com/questions/3219014/what-is-a-cross-platform-rege...
Comment #4
Antti J. Salminen commentedThe problem is not operating system specific. The reason is that the browser sends newlines always as \r\n. Every value of formids has a carriage return (\r) at the end if the splitting is done with \n as the delimiter. Attached is a patch for the issue, it also removes some excess whitespace and adds the site contact form to the list of predefined form ids.
Comment #5
vertikal.dk commentedThis has been fixed in the latest version of the module.
Martin