I've been trying to figure out how to shrink down the form fields of the Drupal 7 version of the Date module, but I have not been able to find anything that describes how to do it.

What I want to do is convert a date form field from something like this:

+-v The date field's title ----+
| +--------------------------+ |
| | Date                     | |
| | +------------+           | |
| | | 2010-01-12 |           | |
| | +------------+           | |
| | Description              | |
| +--------------------------+ |
+------------------------------+

to something like this:

The date field's title
+------------+
| 2010-01-12 |
+------------+
Description

Basically, removing the field set and the extra box between the field set and the text field, and replacing "Date" with the title of the field.

Where can I find information on how to do this?

Thank you.

CommentFileSizeAuthor
#9 date field.png9.94 KBkarimiehsan1819
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joppert’s picture

I've got the same question/issue
Hope someone can point us in ht eright direction

drupso’s picture

An alternative is with CSS using display:none in label Date and set border: none in first & second fieldset. It's possible other way (a theming date function with code) ???

Regards

chaiwei’s picture

I end up create a simple module to overwrite it.
example below.

function MODULENAME_form_alter(&$form, &$form_state, $form_id){
  if ($form_id == 'CONTENTTYPE_node_form'){ 
      // remove date field fieldset
      $form['field_DATEFIELDNAME']['und'][0]['#theme_wrappers'] = array('form_element'); 
  }
}
anrikun’s picture

Title: Formatting/theming date form fields » Improve date field formating/theming
Category: support » feature

Turning this into a feature request:
- the way date fields are themed does not respect the way other core fields are themed. Especially that fieldset that seems to annoy a lot of people here.
- date fields break W3C validation.
IMHO this really need some improvement.
I'm OK to submit patches.

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

Is this now a duplicate of #1538072: Date field rendering does not conform to Drupal field standards -- or vice versa? Let's focus on specific issues and one topic per issue.

oadaeh’s picture

Title: Improve date field formating/theming » Formatting/theming date form fields
Category: feature » support
Status: Postponed (maintainer needs more info) » Fixed

I am all for having better theme override options for the date fields. However, that is not the issue I posted. I simply wanted to find out what was possible, and how to get where I wanted to go.

Thank you drupso for your suggestions.
Thank you chaiwei for your code sample.
With my own poking around, they both helped me reach my goal.

In addition to the hook_form_alter code, here is what I have in an included .css file:

.container-inline-date .form-item {
  border: none;
}
.container-inline-date .date-padding {
  padding: 0px;
}
.container-inline-date label {
  display:none
}

As far as I am concerned, this issue is fixed.

anrikun, I recommend you start a new issue. If you need this issue as a reference, you can link to it.

Again, thank you all.

Status: Fixed » Closed (fixed)

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

ranga143’s picture

thanks ..its working fine........

karimiehsan1819’s picture

Issue summary: View changes
FileSize
9.94 KB

hi , i want remove or hide border of date field , how can i do it?

oadaeh’s picture

@karimiehsan1819, based on your screen sot, that looks like just a normal text field, so you should be able to use CSS to remove the border.

parveroshan’s picture

#3 is worked for me.. thank you so much :) :)