I'm at a loss here, I've been googling, digging through form.inc and module code but I can't figure this one out.

All I'd like to handle is this: user submits a form with the Save Draft button and I want to detect that, and set #validated to true for any control that already has #required set.

My specific case is related to Webfrom - http://drupal.org/node/226907 (trying to do what's described in comment #48) - but it should be the same as any form submit/validate processing.

I'm open to other suggestions, like considering removing the #required flag and implementing it as custom validation.

I have a function that can find & flag all the #required controls as #validated but I'm getting hung up finding the right place to do it. I've tried doing it where the form is built but it doesn't seem to get be getting rebuilt when the Save Draft button is clicked.

Comments

jaypan’s picture

You said it yourself - remove the #required and perform a custom validation.

Contact me to contract me for D7 -> D10/11 migrations.

Brigadier’s picture

Thanks for the vote of confidence. It's just that the fields are required on final submission so I'll end up adding the classes to each element so the user has feedback that it's required. I'm coming around to the idea. Guess I have some validation code to write.

jaypan’s picture

You can add:

<sup>*</sup>

to the title, and it will add a superscript asterisk. You can then style it red using:

label sup
{
  color:red;
}

the only problem you may come across is that titles are probably run through check_clean(), meaning it will either strip the tags, or encode them so that they aren't rendered. If that is the case, you will have to look for a way to render titles without going through check_clean().

Contact me to contract me for D7 -> D10/11 migrations.