I am new to Drupal. I am currently assigned to creating webforms. I have added a date field to my form and will like to know how to set the default date to automatically fill with the current date. When users use this form, the date will always be the current date, so I do not want or need for them to enter this information.

Comments

Jedd Casella’s picture

It's been a while since I've built a webform but from memory - you just edit your textfield and enter %date in the default value field (on the edit page) to get the current date.

Hope that helps.

fuzzbuzz’s picture

I apologize again for a late response, but as I mention to DebMorris, I never got notified that there were responses to this question.

Today I had to autopopulate the current date in another form so I had to revist this problem. I googled it and it brought me to my own post. But, I tried %date as the default value with and without the "popup calendar" enabled and it did not do anything. But, just entering "today" without any qoutes and disabling the "popup calendar" did work.

Thanks for your help.

sean.walker@nreca.coop’s picture

I believe what the first post said was to create a "Text_Field" and give the description of "%date". This works beautifully for a text field, but maybe not for a date field type (although today works for date fields -- as you already found out).

You can take the text field one step further by making it "disabled", which basically allows for the display of today's date while keeping the field uneditable by your site viewers.

This would be the implementation path I would take since you aren't asking your visitors to actively change the date, a date field isn't really needed. You can just populate a text field with the information automagically.

DebMorris’s picture

In the default value for the field, enter 'today' (no quotes).

fuzzbuzz’s picture

I am sorry for posting this so late, but I never got notified that I had responses to this question. I had gave up until today when I needed to autopopulate a date field again.

Sorry, but %date did not work at all. At first just putting "today" as default value without quotes didn't work either.

When I disabled the "popup calendar" first, then as DebMorris said, I simply put 'today' in the default value without any qoutes, and the date was autopopulated with the current date.

Thanks a million!