path disappears after previewing node

aarakast - May 25, 2008 - 09:55
Project:Pathauto
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:dropcube
Status:closed
Description

After showing the preview of a node, the edit-path input field is empty if you have defined an individual path for that node, after saving the idividual path is overwritten bei the automatic entered path.

#1

greggles - May 25, 2008 - 16:07
Component:User interface» Code
Status:active» needs work

Thanks for the report - I can confirm this issue and also found that the state of the "perform pathauto alias" checkbox is not remembered.

I tested the edit-path problem after disabling javascript and found that the form value is persisted. So, one option would be to use some jquery to un-disable the edit-path or we are either going to have to add some logic that sets it to the proper value on a preview.

For the checkbox, I think that instead of #default_value => TRUE we should consider using the $form['#node']->pathauto_perform_alias) value if it isset.

This attached patch covers the second problem.

AttachmentSize
262464_1_pathauto_path_textbox_checkbox_should_persist.patch 1.33 KB

#2

greggles - May 25, 2008 - 16:09

Also, this only affects 6.x - so perhaps there is something wrong with the way that the form_alter was upgraded from 5.x and this could be fixed more simply...

#3

dropcube - May 25, 2008 - 22:19

Also, this only affects 6.x - so perhaps there is something wrong with the way that the form_alter was upgraded from 5.x and this could be fixed more simply...

The problem is that in 5.x, the node is submitted for preview using a button, form element, and not a submit form element. The button> element has #executes_submit_callback set to FALSE (see system_elements, which means that the form is not really 'submitted', it is re-built with the submitted values. The path is not submitted beacuse the field is disabled, but the node path is used as the default value.

However, in 6.x, the preview button has its own submit handler. When summited, the form is proccessed and the node values are overwritten with the form values. For this reason, the path value is lost when the field is disabled.

#4

dropcube - May 25, 2008 - 22:37
Version:6.x-1.0» 6.x-1.x-dev
Assigned to:Anonymous» dropcube
Status:needs work» needs review

Here is a patch that fixes this. The path is saved in a form value and restored back to the text box after the form submission, following a similar hack to the one used in the pathauto_nodeapi presave.

AttachmentSize
pathauto_node_preview-262464-4.patch 1.82 KB

#5

aarakast - May 26, 2008 - 10:01

For me it still doesn't work...
node -> edit -> uncheck "automatic alias" -> enter new alias -> save -> edit node -> save -> new alias is replaced by autoamtic alias
While editing the second time "automatic alias" is checked again..

#6

dropcube - May 26, 2008 - 13:20

This issue is related to persist the values of the checkbox and the path when submitting a node for preview, like it works in 5.x versions. Did you test the node preview as you reported initially ?

#7

aarakast - May 26, 2008 - 15:49

Ok ;) That works now. Thanks for that!
Should I now create a new issues concerning the checkbox?

#8

greggles - May 28, 2008 - 02:04

#9

Freso - June 1, 2008 - 10:23

freso@nayru /s/h/l/h/d/s/a/m/pathauto> patch -p0 < pathauto_node_preview-262464-4.patch
patching file pathauto.module
Hunk #1 FAILED at 261.
Hunk #2 FAILED at 286.
2 out of 2 hunks FAILED -- saving rejects to file pathauto.module.rej

Re-rolled. Will test now.

AttachmentSize
pathauto_node_preview-262464-8.patch 1.87 KB

#10

Freso - June 1, 2008 - 10:39
Status:needs review» reviewed & tested by the community

I don't see anything wrong with the code, and it works as advertised.

#11

greggles - June 9, 2008 - 17:10
Title:Individual path is away after opening preview» path disappears after previewing node
Status:reviewed & tested by the community» fixed

rerolled one last time...and committed.

Thanks Dropcube and Freso!

AttachmentSize
262464_pathauto_node_preview_11.patch 1.94 KB

#12

Anonymous (not verified) - June 23, 2008 - 17:12
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.