Closed (fixed)
Project:
Drupal core
Component:
node.module
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
30 Oct 2005 at 20:26 UTC
Updated:
18 Jan 2006 at 09:21 UTC
Jump to comment: Most recent file
admin/settings/node has a setting for "Preview post" as optional or required. Setting this to required sets "node_preview" in variable table, but this doesn't seem to be used anywhere. I see both Preview and Submit buttons in create new page or new forum topic in today's cvs.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | node_preview_4.patch | 1.21 KB | DriesK |
| #4 | node_preview_3.patch | 1.25 KB | DriesK |
| #3 | node_preview_2_0.patch | 1.25 KB | DriesK |
| #1 | node_preview.patch | 1.4 KB | DriesK |
Comments
Comment #1
DriesK commentedMaking the submit button appear only when 'preview' has been clicked isn't that difficult, it can be done in node_form(), at the place where the submit button array is located now by checking $_POST['op'].
However, we only want the submit button to show when 'preview' has been clicked, _and_ there are no errors in the form. We can't use #post_process, since this is also called before drupal_form_validate() (so renaming it to #after_build as has been suggested would be great). Therefore, the only way I could think of is to use #theme, since theming is the only thing that still happens after form validation. Patch attached for review.
Comment #2
DriesK commentedsomething's wrong. submit is not recognized. I'll try to figure it out.
Comment #3
DriesK commentedI took a look at this one again, and it wasn't simple. I tried several possible solutions, and this one is the only one that works as what one expects from a preview button (only show the submit button after preview, and only if there are no errors in the form).
I integrated the solution with node_form_add_preview() to minimize the number of calls to node_validate() and _form_validate().
Comment #4
DriesK commentedThis one is better.
Comment #5
dries commentedNot sure about this patch. Calling internal form API functions (_form_validate) isn't a good idea, IMO.
Comment #6
DriesK commentedchanged it to drupal_validate_form (which calls _form_validate). I also did some further cleanup of the code, and removed the node_validate call, which is called by _form_validate (I missed that in the previous patch).
Comment #7
chx commentedLet's answer the question: why do you need to call drupal_validate_form? Because you want to include preview only if the form validates. Is there another way to do this? No. As we can see in drupal_get_form , after drupal_validate_form is called (and there is no submit) the next step is theming. We do not want theming to insert the preview. Validate validates and does not change anything. Q.E.D.
Comment #8
dries commentedLast patch looks good. Great work. Committed to HEAD.
Comment #9
(not verified) commented