When you edit a previously saved node which had a pubish_on or unpublish_on value, change the value and do a preview, the old saved value
is put back into the editing form. This is because the dates are retrived from the database during hook_form_alter() when they should be taken from the edited form values.

This patch fixes this problem by checking if $form_state['values']['op']=='Preview' and then using $form_state['values']['publish_on'] and $form_state['values']['publish_on'] instead of retrieving the stored value from the {scheduler} db table.

Jonathan

Files: 

Comments

jonathan1055’s picture

I forgot to say that this is a new issue, split out from #429004: Disallow publish_on and unpublish_on dates in the past.

The changes for the Preview problem in the attached patch in #1 above, all in scheduler_form_alter() as follows:
1. When doing a preview get the default values from the form not the db
2. Testing is now done on the $defaults object not $node
3. Consolidate the logic tests for whether to call scheduler_strToTime
4. Replace tabs with spaces as per drupal coding standards so that indentation is consistent

Hope that helps to explain things.

Also just noticed in the patch file, on the very first line I have not changed the module name from my temporary file name I used to create the diff. I guess you can edit it and change 'scheduler.before_c.module' to 'scheduler.module' before applying the patch. Sorry about that.

Jonathan

Eric Schaefer’s picture

Status: Needs review » Reviewed & tested by the community

Excellent! I always knew there must be a better way, but it always makes my brain hurt just looking at form_alter() and node_api(). Thanks a lot. Will be comitting this later this evening...

Eric Schaefer’s picture

Status: Reviewed & tested by the community » Fixed

Commited.

Status: Fixed » Closed (fixed)

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