I'm doing an heavy usage of this module, which works great, except I need the url form input to be optional (whatever I do then with the value, empty or not, is handled by my own submit handler).

I could alter the returned form myself, but the real errors comes at validation time, required or not, your own validation function test for value, even if the element has not the #required attribute.

I did a really tiny patch, clean, that adds a $required parameter to the purl_form() function and skips the validation when the element is not required AND the value is empty.

CommentFileSizeAuthor
purl-form-required.patch1.41 KBpounard

Comments

pounard’s picture

Title: Remove the required => TRUE into purl_form() function and make it optional » Remove the required attribute of purl_form() value element and fix element validation.

Better title.

pounard’s picture

Note that I did add an optional function parameter, and kept backward compatibility, per default, the element is #required if the parameter is not specified.

yhahn’s picture

Assigned: Unassigned » yhahn

I'll review in greater detail later but at first glance this patch looks fine.

yhahn’s picture

Status: Needs review » Fixed
pounard’s picture

Thanks

Status: Fixed » Closed (fixed)

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