This patch suggests an alternate (hopefully clearer) description for the Form API form_set_error() function, including params and return. I'm not entirely sure the return text is accurate, or well worded, so better suggestions are welcome.

This, of course, will need to be updated if http://drupal.org/node/119208 affects the parameters of the function.

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

looks good. thanks.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

We don't use the edit array on form elements since (maybe) 4.7. So the example needs that removed.

oadaeh’s picture

Status: Needs work » Needs review
StatusFileSize
new899 bytes

Is this better?

oadaeh’s picture

StatusFileSize
new899 bytes

It seems as thought my comments aren't being applied, nor am I receiving any of the notices.

I'm going to try attaching the updated patch again.

gábor hojtsy’s picture

Status: Needs review » Needs work

Hmmm. I suggested removing the edit array not the whole note about nested arrays. The edit array itself was removed the nested arrays are still handled with this construct as far as it looks from form_get_error(), which I just checked.

oadaeh’s picture

Okay, I guess I didn't understand what you meant.

Just for my own clarification, are you saying that "If the name of the element is 'edit[foo][bar]', then you may pass either 'foo' or 'foo][bar' as $name." is no longer valid, but "Passing 'foo' will set an error for all its children." is still valid?

Or, are you saying that "If the name of the element is 'edit[foo][bar]', then" is no longer valid, but "You may pass either 'foo' or 'foo][bar' as $name. Passing 'foo' will set an error for all its children." is still valid?

gábor hojtsy’s picture

This is the text from your patch:

+ *   The name of the form element. If the name of the element is
+ *   'edit[foo][bar]', then you may pass either 'foo' or 'foo][bar' as
+ *   $name. Passing 'foo' will set an error for all its children.

I said we do no use "edit" anymore, so remove "edit":

+ *   The name of the form element. If the name of the element is
+ *   'foo[bar]', then you may pass either 'foo' or 'foo][bar' as
+ *   $name. Passing 'foo' will set an error for all its children.

This is what I said. I did not say anything about whether this is right now or not. I looked into http://api.drupal.org/api/function/form_get_error/6 which says the foo][bar form is supported indeed. Whether passing 'foo' sets an error for all children is a different question. It depends on how form_get_error() is actually used. However, I don't see that this is the case, look into http://api.drupal.org/api/function/_form_set_class/6. It only sets the class or the current element.

So while I pointed out the error with the "edit" element, it did not had any consequences on other parts of the note. Those needed further digging.

chx’s picture

Title: Improve the description of form_set_error . . . » form_set_error doxygen is very poor
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1019 bytes

Well, if we want to be precise then this is the patch you want. Speaking of children is highly innacurate. Note that this patch can be applied to D5 and D4.7 -- though D4.7 did use $edit but this has nothing to do with form_set_error, actually. We need to work on this error setting thing on D7, these legacy functions are ugly to say the least.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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