开发者

Drupal form validation marks other form fields as invalid

开发者 https://www.devze.com 2023-01-11 16:06 出处:网络
I have a problem with multiple forms in one page with inputs sharing the same key. I have a form in a page and another form in a block showing on the same page.

I have a problem with multiple forms in one page with inputs sharing the same key.

I have a form in a page and another form in a block showing on the same page.

Both forms have a field name exactly the key name (mail). I can't change those field's keys or I would break 2 modules.

So, whenever I try to post the page form and the mail is missing (it's required), I'm taken to the same page with that field marked red (which is correct) but the block form is also marked (which is wrong, because I was filling the page form, no the block).

Does anybody know how to avoid this behavior? I'm thinking about hook_form_alter(), or even theme_preprocess_block(), but before reinventing the wheel... well, you know.

Th开发者_如何学编程anks in advance!


Maybe try adding an extra validate function to the block form and if all fields are blank, then do the following:

form_set_error(NULL, '', TRUE);
$form_state['rebuild'] = TRUE;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号