Closed (won't fix)
Project:
Drupal core
Version:
6.x-dev
Component:
profile.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Feb 2009 at 10:10 UTC
Updated:
15 Jun 2011 at 16:07 UTC
Hi,
Im a newb to drupal.
When i submit a registration form on drupal without filling the fields, i get
# Username field is required.
# E-mail address field is required.
# First Name field is required.
# Last Name field is required.
# Address 1 field is required.
# State field is required.
# City field is required.
# Zipcode field is required.
Those are mandatory fields.
How do i remove the big list and display "All mandatory fields are required" instead of displaying each and every field for required.
Thank u
Comments
Comment #1
matt2000 commentedThat's not possible in the core UI.
But assuming you're a coder and have grasped the basics of Drupal development:
You'll need to create a custom module implementing hook_form_alter to specify a new validation function, which will call form_set_errors with $reset=TRUE.
http://api.drupal.org/api/function/form_set_error/6
http://api.drupal.org/api/file/developer/topics/forms_api.html
Comment #2
Sandymaguire commentedComment #3
Sandymaguire commentedThanks matt for ur help...
It explains validation of all the custom made forms rather than the profile registration form which is out of the box in drupal.
I want to modify the registration form validation errors to be "All mandatory fields are req" rather than displaying errors stating
"... field is required"
"... field is required"
"... field is required"
"... field is required"
"... field is required"
"... field is required"
"... field is required"
thank u
Comment #4
stevenpatzComment #5
matt2000 commentedYou can use hook_form_alter on pre-exisiting forms. That's its point.
http://api.drupal.org/api/function/hook_form_alter/6
When you call form_set_error() with $rest=TRUE, it should remove the 'default' error messages, so you can insert your own in their place.
The links I provided weren't intended to walk you through a solution; they provide the general background information you'll need to understand in order to implement the solution I suggested.
Everyone says Drupal has a steep learning curve, and everyone who follows through with it has said it was worth it.
Good Luck!
Comment #6
ainigma32 commented@Sandymaguire: Did you manage to implement your changes using matt2000's pointers?
- Arie
Comment #7
Sandymaguire commentedActually No...
There was a variable $messages that holds the html code like
It seems the value of $messages varies for each page.
Was working on how to break the $messages, put conditions and render our own messages.
Comment #8
matt2000 commentedform_set_errors() populates $messages .
You're going about it the hard way, but if you really want to do that, use drupal_get_messages() :
http://api.drupal.org/api/function/drupal_get_messages/6
But really, use hook_form_alter() and form_set_errors(). Anything else is a waste of time that you will probably regret later.
Comment #9
ainigma32 commented@Sandymaguire: Any luck in resolving this issue yet?
- Arie
Comment #10
Sandymaguire commentedNo, im still working on it..
Comment #11
maxferrario commentedI have a far from perfect solution, but it works for me (I'm using drupal 6).
In the "Webforms advanced Setting"/"Additional validation" field of the webform put the following code:
Please note that this code suppresses the output of every Drupal error, not only errors raised by the webform module nor "mandatory field" errors only. So you will have to validate some fields by yourself, as all the messages from the module are gone.
Hope this helps.
Comment #12
dpearcefl commentedClosing this issue because of a lack of activity.