This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » General » Edit current draft

Edit current draft

Edit current draft

Monday 23 February 2015 2:02:57 pm - 10 replies

I've a project where user can create draft and publish it when everything is ok. Publish is done via cron (after admin check up content). When first draft is created and sent to the publish, admin approves it and object is created. But, if new draft is created (user is able to preview new draft in the frontend) and user wants to edit the draft it opens up current saved object version, not draft's version.
I'm using Community Project 2014.11 (legacy code) for my project.
Any help with this problem?

Monday 23 February 2015 5:24:15 pm

Hello Sebastian,

Welcome to the eZ Community!

When you say, 'if new draft is created', how are you creating this new draft? Are you using the 'content/history' view or are you just clicking edit in admin? While this may not matter I'm just trying to understand better the use case your working with.

When a user clicks edit, a new draft is created with the contents of the last draft.

I'm not clearly understanding you when you say, 'edit the draft it opens up current saved object version, not draft's version'. Can you explain this again in more verbose words? What you have written is just not enough to clearly explain what you are doing, what you expect and what is happening instead.

When edits an existing draft it should by default always edit the draft version not the previous version, though the content of the two versions may be the same until the draft content is changed -and- stored or published.

I hope this helps!


Tuesday 24 February 2015 9:27:08 am

Hi Heath,
Thank you. I will try to explain my problem more clearly.
I've created a custom user class (with user account datatype) in the backend (admin). Users, with that user class, are able to login only on the frontend. They can save some objects in the frontend only.
Custom user logs in and there's a button which opens up create/edit form. There are two buttons in the edit form: PublishButton and StoreExitButton. When the user first time saves object with StoreExitButton he's created a new draft. I fetch those drafts and user is able to edit it more untill he's satisfied with a content. Edit once more, click on publish and content becomes pending. I've setup trigger, content must be checked before it's published. Admin checks up content, approves it and cronjob frequent publishes object. Everything fine for now. User have a list of published content. Click on the edit of the published content opens up an edit form and user saves a draft. That draft appears in the fetched draft list. When user tries to edit that draft, the content of the new draft in the edit form has values of the published content, not content of the draft version.
I can't find the reason why's that. Manage versions in the admin shows me first version (published) and second version (draft). When I check up draft's content it shows the right content in the admin, but that's not the case in the edit form in the frontend. Url is like it should be, content/edit/objectid/version_nr/eng-GB (version_nr=2 -> for the draft object) so url is not a problem for sure.

Modified on Tuesday 24 February 2015 9:33:14 am by Sebastian Clay

Tuesday 24 February 2015 9:48:19 am

I think what you want to do is add:


to your frontend site.ini.append.php under [ContentSettings]

Wednesday 25 February 2015 9:48:52 am

I've already added the mentioned setting in the siteaccess ini, cleared caches (global and siteacess) but problem is still here.

Wednesday 25 February 2015 11:26:58 pm

Problem is caused by override template, but I didn't find how to resolve the issue. When I remove override for edit from myextension/setttings/mysiteaccess/override.ini.append.php, default design/standard/templates/content/edit.tpl shows up and content is the right one (from draft version).
But, if I put back my override template, it shows content of the published object, not draft's.
I've overriden edit template for my_class like this:


My edit template is placed in extension/myextension/design/mysitedesign/override/templates/myclassidentif.tpl

Also to mention that there's nothing unusual in my edit template that should cause this problem.
I suppose that there's some bug in the kernel..
Any further help?

Modified on Wednesday 25 February 2015 11:28:55 pm by Sebastian Clay

Thursday 26 February 2015 1:48:58 am

Hello Sebastian,

I'm sorry to say but I strongly do not think this is a bug in the kernel. Especially after all you have shared.

Since you know it works without the template override you know for certain it's not a kernel bug.

Can you please share the source code of your template override via Gist here in the forums for comparison and review. If you would share the source then we can certainly help you compare the custom template and the default and find the differences which matter here.


Thursday 26 February 2015 5:34:14 pm

I've added my code of template override to the gist.
Please let me know if there's anything that could resolve the problem. Thanks.

Modified on Thursday 26 February 2015 5:37:04 pm by Sebastian Clay

Thursday 26 February 2015 6:57:52 pm

Hello Sebastian,

Thank you for sharing your template overide via gist! This really helped me.

I think a part of your problem comes from where in the default template the system calls: {include uri="design:content/edit_attribute.tpl"}

Instead in your custom template override you have static code replacing this template include.

I know you need / want your custom template logic (which is fine, I see no problem with that in theory).

What I would recommend is extending your existing template override solution a bit further.

First, test again with your template override enabled and comment out your custom attribute form code and instead include this via adding: {include uri="design:content/edit_attribute.tpl"}

If that works then the next step is to create a custom design extension template ie: content/edit_attribute_custom.tpl and change the include to {include uri="design:content/edit_attribute_custom.tpl"} and then -within- content/edit_attribute_custom.tpl add your custom code features within the existing code -without- breaking the key feature you require. 

As I am looking at the template in question you may need to review the default templates logic used for your attribute datatypes (as used by attribute_edit_gui).

For those reading alone, this is what the default template for content/edit_attribute.tpl looks like:

If you want to save time you can skip the edit_attribute_custom.tpl and just add the template code used by attribute_edit_gui into your existing template override (test to ensure this works as needed) then add your custom code.

I hope this helps!


Friday 27 February 2015 12:36:44 am

Thank you Heath! You helped me.
When I included standard edit_attribute.tpl and commented out my code, the content showed as it should be. I've put all in edit_custom_attribute.tpl and everything is ok now.

Friday 27 February 2015 12:50:04 am

Hello Sebastian,

I'm very happy to have been able to help you solve your problem!

Thank you for being so patient and dedicated to solving the problem.

Feel free to ask again for help here in the forums!

Best wishes 



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from