Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By morganhua on
Is there a configuration for removing the asterisks from required fields? Is it a style of some sort? If not, does anybody know which module/file/function in the core I can hack to remove the asterisks from all the required fields?
Comments
Use styling
I think the simplest way to remove asterisks is making
form-required
CSS class hidden. Drupal wraps asterisks in a span tag. So addingto your theme's CSS file will remove asterisks visually.
:: I am not sure if
display: none;
is right, I am not so familiar with CSS.--------------------------------------------------------------
http://erdemkose.com/
Drupal Turkiye
That worked great!
also works and keeps the spacing, but since the asterisk is always at the end of the field, "display: none" worked fine.
And no real coding required. Thanks.
Oddly enough, when I tried
Oddly enough, when I tried this, visibility:hidden worked but display: none didn't. I had to add !important to get it to work.
I'm pretty sure that there
I'm pretty sure that there is no web admin setting for the red asterisks. They are a widely used de-facto standard, so my recommendation would be to leave them in place. Many users will recognize them for what they are.
If you still want to remove them, you may have to delve into PHP programming. Or perhaps there is a way to make them invisible in one of the CSS sheets.
Sorry for not having a definite answer. But I just saw that somebody posted a more concrete proposal while I wrote this.
Hans-Georg
theme override
Add a theme override for the form_element themable.
http://api.drupal.org/api/5/function/theme_form_element
http://drupal.org/node/11811
What file is this in? Thanks.
What file is this in? Thanks.
How to remove asterisks from login form
To remove asterisks from the login form add the following code to your theme's style.css:
This will only affect the login form. To remove asterisks from everywhere use:
In a Drupal 7 module
Here it is in a D7 module with a specific NODE-TYPE:
And here it is for the user form:
It's simple, you can use
It's simple, you can use "theme_form_element" function:
Instead of$required =
Instead of
I would suggest
For those that want to remove
For those that want to remove the asterisks from some forms and not others I did something similar.
Notice this part
Then you can simply add in a form alter
One more solution to remove * from required field on site forms
For Drupal 7 you can
For Drupal 7 you can overwrite THEME_form_element in your theme. All classes on the fields stay for styling purposes, Ex. required, error,..