Hi,

In my web page I have an input like this :
<input id="edit-before" type="hidden" value="" name="before"/>

But I can't post any data to this form :

 $edit = array('before' => 1);
 $this->drupalPost('user/edit', $edit, t('Validate'));

It answers me :
Failed to set field before to 1

It works with text input.

Am I doing something wrong ?

Thanks.

CommentFileSizeAuthor
#2 drupal_web_test_case.inc_.patch431 bytesstyhe_

Comments

dave reid’s picture

Status: Active » Closed (works as designed)

SimpleTest currently only allows you to submit 'visible' fields. If you want a hidden field on your form, you should be using the FormAPI #type='hidden'. We are working on the potential to submit 'extra' POST data. See #335035: drupalPost() incorrectly submits input for disabled elements.

styhe_’s picture

StatusFileSize
new431 bytes

I simply add case 'hidden': in the switch of the function 'handleForm' in 'drupal_web_test_case.inc' and it works.

chriscohen’s picture

Version: 6.x-2.7 » 6.x-2.9
Status: Closed (works as designed) » Reviewed & tested by the community

Bump. It's pretty ridiculous that as it currently stands, I cannot post hidden fields. My module code uses hidden fields to store a 'calculated' value from some jQuery-powered form elements, and unless simpletest allows me to post hidden fields, it is not useful at all.

I can confirm this patch works, even with 6.x-2.9, although drupal_web_test_case.inc appears to be called drupal_web_test_case.php now.

damien tournoud’s picture

Project: SimpleTest » Drupal core
Version: 6.x-2.9 » 7.x-dev
Component: Miscellaneous » simpletest.module
Category: support » feature
Status: Reviewed & tested by the community » Active

This needs to be considered in core first.

proppy’s picture

Hi,

I found the same issue in D6:
http://drupal.org/node/643918

Would you consider backporting styhe_'s patch ?

FYI, it applies well on simpletest-6.x-2.9:

drupal-dev:/usr/src/simpletest# patch -p2 < /tmp/drupal_web_test_case.inc_.patch 
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/core/drupal_web_test_case.inc b/core/drupal_web_test_case.inc
|index 9e95f13..0bfb53b 100644
|--- a/core/drupal_web_test_case.inc
|+++ b/core/drupal_web_test_case.inc
--------------------------
File to patch: drupal_web_test_case.php
patching file drupal_web_test_case.php
Hunk #1 succeeded at 1646 (offset 391 lines).
j_ten_man’s picture

Subscribe

c960657’s picture

Project: Drupal core » SimpleTest
Version: 7.x-dev » 6.x-2.x-dev
Component: simpletest.module » Code

This was fixed in core with the patch for #595876: Taxonomy term reordering fails.

Stalski’s picture

subscribing for drupal 6 and indeed patch works.

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Active » Fixed

Committed.

Index: drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/drupal_web_test_case.php,v
retrieving revision 1.2.2.3.2.46
diff -u -p -r1.2.2.3.2.46 drupal_web_test_case.php
--- drupal_web_test_case.php    6 Nov 2009 21:23:32 -0000       1.2.2.3.2.46
+++ drupal_web_test_case.php    27 Jan 2010 01:54:51 -0000
@@ -1649,6 +1649,7 @@ class DrupalWebTestCase extends DrupalTe
         switch ($type) {
           case 'text':
           case 'textarea':
+          case 'hidden':
           case 'password':
             $post[$name] = $edit[$name];
             unset($edit[$name]);

Status: Fixed » Closed (fixed)

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