Closed (won't fix)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
28 May 2015 at 16:16 UTC
Updated:
17 Nov 2020 at 18:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
yaach commentedActually I just enable Node Clone module and although it allows me to clone a Webform Node, it DOES NOT allow me to clone a submission.
Anoybody?
Comment #2
danchadwick commentedThis will require custom programming. You can add a command to do the clone. You can then add the link from the view that generates the list of submissions (webform_submissions or webform_submission_NID).
Comment #4
yaach commentedHi All,
Thanks to @DanChadwick suggestion, I have implemented the feature to clone submitted data. This works pretty much like the edit or delete commands:
In order to enable the Clone feature, do the following steps:
The goal that makes me create this feature was because I am doing a very long form that users fill out in a yearly basis, then next year they need to fill out the same form and most of the time all the fields are the same.
Hope that helps anybody needing this.
Comment #6
danchadwick commentedThis is nicely done. I am willing to commit parts of this so that someone can add a clone link to the view if they want. I don't want to add a clone tab, but someone would enable that using hook_menu_alter to change the MENU_CALLBACK to a LOCAL_TASK.
I read the patch over and have these comments:
I don't think the delete method should be invoked. The submission is still valid in the original submission.
Request time should not be set if it is 0 (i.e. a draft). If you clone a draft, it should not get a complete timestamp.
We could make the a menu callback. Users could then change it to a local task with hook_menu_alter to make the clone tab appear.
I think the permission for clone should be the same as VIEW and SUBMIT. If you can view the submission and can submit the form, then you could copy the submission down with pencil and paper and submit a new one.
Also not needed.
Comment #7
danchadwick commentedComment #8
yaach commentedHi Dan,
Not sure if I understand well your comment #5 on the patch. Every user will
have the ability to clone their submitted data and I am using the "View your
previous submissions" option so that users can see their list and clone from
there. Last time I checked, I couldn't get the clone link on the view unless
I set permissions.
Thanks
Comment #9
danchadwick commentedWhat I mean is that I would propose to NOT introduce new permissions for Clone. Instead, the permission to clone would be the relevant permission to view the particular submission PLUS (logical AND) permission to create a new submission, because that's what clone is functionally.
You would still need to customize your particular view to include the clone link, and, if you want it, convert the Clone menu callback into a local task to make the tab appear. I would love to find a way to infer whether the user wants to allow cloning, but I don't know what that would be. We can't go looking for the clone handlers in the view, for example.
Comment #10
yaach commentedOk, so I made some changes for the feature based on @DanChadwick suggestions and comments.
Comment #12
yaach commentedHi Dan,
Does this new feature will be merged anytime soon?
Thanks
Comment #13
danchadwick commentedWe need to get tests working first. If you can help with that, it will speed things. I'm also on vacation for a few weeks so won't be working on code for a while.
I still support the feature tho.
Comment #14
yaach commentedSure I will make some tests..enjoy.
Comment #15
danchadwick commentedSorry to not be clear. I'm not looking for clone tests, although they are welcome. Existing tests don't pass. That needs attention.
EDIT: This: #2510216: Tests are failing (Testbot, local via UI, drush test-run
Comment #18
danchadwick commentedComment #20
danchadwick commentedI installed and tested your patch.
In general, there are two approaches for cloning content:
1) Clone the content, then allow the user to edit the clone.
2) Create a new piece of content with the form already filled in with the cloned content.
Webform already clones components and uses approach 2. I was surprised when cloning a submission, it used technique 1. If technique 2 were used, there would be no need for a confirming page prior to the clone. webform_client_form() accepts a $submission argument, which could be created from the cloned submission and adjusted to create a new submission. At a minimum, you would need to remove or set the sid, serial, and dates as needed. Maybe other stuff too.
Also, I don't see that all the needed permissions are correct. What exactly they are would depend upon which cloning approach is used.
1) To clone-and-save, you need permission to view the submission plus permission to add another submission, including checks that are made on the node view page (where new submissions are made), plus permission to edit the submission (because to change the clone you need to edit it).
2) To add-with-clone-data, you need permission to view the submission plus permission to add another submission. You don't need the edit permission.
Comment #21
danchadwick commentedClosing for lack of activity. Please do re-open if there is continued work on this.
Comment #22
kyleheney commentedHi,
I see that this is closed, but I just wanted to add my desire to see a feature like this added to Webform. Cloning Submissions would be very useful for me, as I use Webform to create invoices, etc... it would be great if a user could clone a previously created invoice so they have some information pre-filled and would only need to add/update certain fields.
It seems like permissions are holding this up a bit, but if it gets looked at again, I'd be happy to help test it and/or contribute where possible.
Thanks
Comment #23
yaach commentedHi @kyleheney, you can try the patched I provided. It worked for me. Get it a try and let me know.
Comment #24
kyleheney commentedI'm hesitant to implement a patch that the maintainer of Webform won't consider. I use webforms throughout my site, so if this feature isn't properly supported, a future update could break my forms. I don't think I'm comfortable trying this unless @DanChadwick were to implement it in the Webform module.
Comment #25
kyleheney commented@yalegria... does your patch only work when a user has the "edit submission" permission? In my case, my user does not have the edit submission permission (just view submission), so I'm not sure if your patch would work for me.
Ideally, I'd only want the user to be able to edit the cloned content (prior to submission), so a new submission would need to be created that auto-populated the new form with the previous data. If I understand your patch correctly, this is NOT how your patch works...? Correct me if I'm wrong.
Thanks
Comment #26
pixelshrink commentedJust wanted to add my support to this feature, it would be great if it makes it into a future release.
Comment #27
druliner commentedPatch #10 breaks with webform 7.x-4.15 so here's a new on that works with no other changes.
I'd love to see this feature added as well. If someone does work on it I'd prefer permissions option 2 that Dan mentions in comment 20. Also change user to the current user on clone. Thanks community.
Comment #28
akrem.ajroudi commentedthank you druliner for your patch but you must edit this line :
FILE : webform\views\default_views\webform_submissions.inc
$handler->display->display_options['fields']['clone_submission']['field'] = 'delete_submission';
TO :
$handler->display->display_options['fields']['clone_submission']['field'] = 'clone_submission';
Comment #29
drumanuel commentedNeeded this patch for 4.18 so I ported it and it seems to work nicely
Comment #30
drumanuel commentedComment #31
rex.barkdoll commentedHi @Drumanuel,
Thank you very much for posting an updated version of your patch.
I just tried to implement it with Webform version 7.x-4.23. Something seems to break and I don't have the coding chops to understand what's gone wrong.
If I disable "Verify submission access for each link" I can get the clone button to show up, but it only sends me to a result detail page and doesn't prompt me for any further action.
I know we're all in the process of moving toward D8, but I've got a few clients who are asking me to see if we can get this working in the mean time.
Thanks for all your work and if you can spare any time on this now :)