Download & Extend

Schedule form to be active/deactivate (open/close) on specific dates?

Project:Webform
Version:6.x-3.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

what i would like to do is create a form that allows submissions on date X and stops allowing submissions on date Y and prior to date X it displays message A instead of the form and after date Y the page displays message B instead of the form.

i don't want to publish/unpublish the form on specific dates, as i want the url to be available at all times, i just want the form to be available at that url between the specific dates.

is this possible? it seems like it would be something that a lot of people may find useful...

Comments

#1

Title:schedule form to be active/deactivate on specific dates?» Schedule form to be active/deactivate (open/close) on specific dates?
Version:6.x-2.9»
Category:support request» feature request

Thanks, no this currently isn't directly possible. There have been some other issues concerning things like "limit to x number total submissions". See the Webform handbook pages on Limiting submissions through Additional Validation, which could be adapted to work for dates also.

I'm moving this to a feature request for the 3.x version.

#2

Version:» 6.x-3.0-beta6

I have a patch for this (first one, so very sorry if I haven't got it quite right) - it adds start/end date columns and displays them on the "Form Settings" tab.

Let me know if there's anything else I can do to help?

Thanks,
-mollyp

AttachmentSize
webforms6.3-beta6.patch 10.07 KB

#3

Status:active» needs review

oops. Needs review please

#4

Thanks smilie62! I think it would also make sense to include a straight-up enable/disable option as part of this patch, so I've marked #868486: Easier mechanism to open/close forms as a duplicate.

Right now I'm focusing on getting out a 3.0 final version, so this may have to wait until after the initial 3.0 release. The patch looks like a great starting point. Thanks!

#5

Ok, great, hope to see this soon!

#6

+1

#7

Version:6.x-3.0-beta6» 6.x-3.2
Status:needs review» needs work

This will need rerolling for the latest version. Rearranging the settings on the form may be necessary to make this option fit in a logical place.

#8

Hi, I'm looking for this exact functionality in webform module and was wondering if there are any updates on progress. This sounds like a very excellent feature for Webform which is an amazing module. Thank you all for your excellent work.

#9

Just poking my head back in here to see if anyone has had a chance to think about an update / road map.

Thanks for any updates!

#10

Status:needs work» needs review

Adding an updated patch against version 3.2. Seems to work pretty nicely.

AttachmentSize
webform-6.x-3.2-start-end-dates.patch 8.96 KB

#11

Sweet, thanks attheshow!

Some comments:

+  $current_tz = date_default_timezone_get();
+  date_default_timezone_set('UTC');

This introduces a dependency on Date API. I'd prefer to use Date API if it's available and use the normal Drupal (not very good) date handling we have available if it's not available. Perhaps some of the code within components/date.inc could help us here.

+  // Add the new start & end date columns.
+  db_add_field($ret, 'webform', 'start_date', array('type' => 'varchar', 'length' => 255, 'default' => 'NULL'));
+  db_add_field($ret, 'webform', 'end_date', array('type' => 'varchar', 'length' => 255, 'default' => 'NULL'));

These should probably be stored as timestamps so that they can be sorted on and displayed consistently. I'm not a big fan of the big textfield to enter your own date/time, though I know it's what Drupal defaults to normally (like when you set the published date on nodes). Not sure what to do about that quite yet.

#12

Version:6.x-3.2» 6.x-3.x-dev
Status:needs review» needs work

This feature is badly needed, so great to see some work being done. However, I have some thoughts.

If we add the ability to Publish/Unpublish a webform, and add an API function to alter this state, setting a webform to be published/unpublished on a schedule could be done with Rules. No need to have this functionality in the module. I might be able to get a patch going for this this week.

#13

Component:Miscellaneous» Code
Status:needs work» needs review

I've given this some thought, and this does seem to be the easiest way forward for now. The Rules part will have to come later (in another module).

Updated patch:

fixes the update function number.
saves dates as timestamps, with an int column as Drupal core does it.
adds a new param to theme_webform_view_messages - date_disabled.

date_default_timezone_get() and date_default_timezone_set() are PHP functions, not Date API, but might not be the Drupal way, I'm not sure. I've left them in for now.

@TODO
Add setting for disabling form.

AttachmentSize
690894_webform_start_end_date.patch 10.7 KB

#14

Thanks blackdog, this patch looks really good. A few things:

- We're including the date.inc component now in the webform.pages.inc file. I didn't see any functions that we used from this file though (probably _webform_strtotime() was the reason you considered including it).
- Reusing our existing time handling would be great, perhaps we should move it into webform.module instead of having date.inc and time.inc (and now webform.pages.inc) depend on each other.
- Don't forget to set a default start_date and stop_date in webform_node_prepare().
- Use sentence case for labels: t('Submission Start Date') should be t('Submission start date')
- End your comments with periods.

Great patch!

#15

Updated patch:

Moved all date & time functions to webform.module to be used by other files (and also, possibly other modules' components from now on).
Fixes all other comments in #14.

Still @TODO
Add setting for disabling form.

AttachmentSize
690894_webform_start_end_date_2.patch 23 KB

#16

Also, we should try to reuse the code you use in date.inc for the date_popup elements, so we can use it for other date fields/elements. Possibly a theme function, or just a function?

#17

subscribe +++++++++++++++++++++++++++++++++++++++++++ Awesome!

Does this allow the text on the node to display, but the form to deactivate. This would be ideal! Like that the node is still valid and has content, but the form is just no longer valid.

#18

@ #17 - Yes, that is what this patch do.

#19

Updated patch adds the possibility to unpublish a form.

AttachmentSize
690894_webform_start_end_status.patch 23.91 KB

#20

+1

#21

I don't think the "published" options belong in this patch. You can use modules like Scheduler for publishing/unpublishing.

#22

You can't use Scheduler to only unpublish the form, only the whole node.
This setting is for closing submissions to a form, but still show the node content.

#23

Ah! Right sorry about that. I was confused when reading your patch by the terminology "Published" and "Unpublished". I think better terms would be "Open" and "Closed" (like Poll module).

#24

You're right. I was looking for the right terminology. Updated patch attached.

AttachmentSize
690894_webform_start_end_status_2.patch 23.87 KB

#25

Okay I tried this patch out and it does work... but at the same time I'm feeling much less confident about its inclusion. Scheduling has a lot of caveats that need to be addressed properly:

- The UI for entering dates is poor (plain textfields). Support for date_popup would be an obvious improvement, though I'm not really a fan of that approach (textfield + calendar) either.
- Timezone handling? What timezone are these dates entered in? Sometimes in my testing I don't even have a time included at all (since my "medium" date format doesn't include time).
- I find it weird that a form can be "Open" but then be forced closed by the date restrictions. Seems like the status should reflect the same status as defined by auto-schedule options.

A larger issue than the UI ones however is that I don't think this is functionality needed by the majority of Webform users. However this patch definitely includes some good ideas (separating out the date functions into webform.module, the "status" column, and being able to close forms more easily). I've rerolled the portions that I think make sense to include immediately and ported to D7 in these patches. This approach makes it at least possible to make a webform scheduler module, which is what I'm going to try to advocate instead of including a scheduler directly in Webform itself.

I've committed these patches to CVS, we can continue discussing the value of scheduling options directly in Webform core or we can just move these options into a dedicated module.

AttachmentSize
webform_status-d6.patch 17.45 KB
webform_status-d7.patch 17.54 KB

#26

Status:needs review» active

Good stuff! I agree that the scheduling stuff can live somewhere else, and now it might even be done with Rules. Thanks!

#27

I've had a chance to test this patch out. It would be awesome if it was broken out in to a webforms scheduler module or something the like. Since webforms operate so much differently than nodes in certain ways, I think it's okay to use a dedicated to webforms module. If rules integration were possible, that would more or less be webforms nirvana... I haven't got a lot of php experience but I can try... and I can test.
Will keep my eyes peeled on this thread.
thanks for all of your hard work!
-adam

#28

Quicksketch said: "- I find it weird that a form can be "Open" but then be forced closed by the date restrictions. Seems like the status should reflect the same status as defined by auto-schedule options."

could you elaborate/explain what you mean by that?

and as far as whether this is needed by a majority or not, i can't comment, but i know i had this request given to me by 3 or 4 of my web authors. and the reasoning seems quite valid. they all have forms that only accept submissions during specific date ranges of the year (like the first 5 days of every month, or once a semester), but they want the url, with relevant information on it, available all year round. so instead of creating a separate node, and playing the "publishing/unpublishing/url alias swap" game, it seemed that the better solution would be to incorporate this into the form itself. at least that's the reasoning behind the request in the first place.

#29

Status:active» closed (won't fix)

I'm moving this issue to won't fix. This can now be implemented through an add-on module and toggling the $node->webform['status'] property or updating the "status" column in the webform database table. This functionality won't be added directly to the module.

#30

What about the new module intended to handle the dates of closing / opening webforms ?
I tried the patch with 6.x3-11 version of the webform module and it failed.

#31

Status:closed (won't fix)» active

#32

Don't you hate it when people re-open issues that have been closed by the maintainer? :)

#33

Status:active» closed (won't fix)

That patch in #25 is already in Webform 3.11. It adds the ability to manually open/close a Webform for new submissions. I am not sure if a webform_scheduler (or something like that) module was ever written or if it made its way back to drupal.org.

In any case, the reason I marked this won't fix is because I won't be adding this scheduling feature to Webform. Perhaps contacting nimzie or blackdog might yield some answers.

#34

Thanks for your response.
I just re-opened this issue to have a response, of course I understood that this feature will not be fixed.

nobody click here