Download & Extend

Allow drupalPost() to specify what form_id to submit to if multiple

Project:Drupal core
Version:7.x-dev
Component:simpletest.module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

The problem arises on pages that have multiple forms with the same submit button text. There is currently no way to specified which form you want to submit. We need an extra parameter or something that allows the form_id or something unique to be passed in order to specify which form to submit.

I thought there was a previous issue for this, but I can't seem to find it. Since #335035: drupalPost() incorrectly submits input for disabled elements will condense the drupalPost() parameters I would like for it to get in before we patch this.

Comments

#1

I've run into this while trying to assign an action to a trigger where there are multiple forms all with the same select option and button name. I ended up doing a direct INSERT instead but would rather be able to use drupalPost().

#2

#3

Status:active» needs review
AttachmentSizeStatusTest resultOperations
simpletest_drupalPost_form_id.patch3.92 KBIdleFailed: Failed to apply patch.View details

#4

I ran into this today. Will try to test/review later.

#5

Status:needs review» needs work

Whats missing from this patch is the test to make sure it works :-D

#6

There was a different issue (can't remember) that added parameters to drupalPost and it merged them into a single options array which was way cleaner...perhaps if someone can find the issue we could get that in or implement in this issue.

Not a stopper to this patch of course, just a suggestion.

#7

Status:needs work» needs review
AttachmentSizeStatusTest resultOperations
simpletest_drupalPost_form_id.patch9.36 KBIdleFailed: Failed to apply patch.View details

#8

drupalPost() already has a lot of arguments. I wonder whether it would be better to supply the form_id as part of the $edit array?

I.e. like this:

+    $edit = array('form_id' => 'simpletest_test_multiple_form_0', 'test_field' => 4);
+    $this->drupalPost('simpletest-test/form-post', $edit, t('Submit'));
instead of like this:
+    $edit = array('test_field' => 4);
+    $this->drupalPost('simpletest-test/form-post', $edit, t('Submit'), 'simpletest-test-multiple-form-0');

form_id already occurs as a hidden field, so there is no risk of colliding with an existing field name.

#9

#335035: drupalPost() incorrectly submits input for disabled elements is the route I think is best in regards to arguments.

#10

Status:needs review» needs work

The last submitted patch failed testing.

#11

#360023: Update node_comment_statistics during "Publish comment" action has been postponed on this - a change which I think is very important to make core Drupal have a complete set of actions for content moderation. Can this still be considered for D7, or #335035: drupalPost() incorrectly submits input for disabled elements if that supersedes this issue? It would be a shame, imo, if D7 shipped without an action to publish comments, since it has an action to unpublish them.

#12

I use different approach for the same task #601398: Simpletest does not allow assigning actions to triggers
But it needs little help with comment

#13

Status:needs work» fixed

Fixed with #601398-60: Simpletest does not allow assigning actions to triggers and that issue has more follow-up.

#14

I need to mention that follow up changes $form_id to $form_html_id - a actual HTML ID of form

#15

Status:fixed» closed (fixed)

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

nobody click here