Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form fields not created when duplicating a page #41

Open
scott-nz opened this issue Apr 30, 2019 · 4 comments
Open

Form fields not created when duplicating a page #41

scott-nz opened this issue Apr 30, 2019 · 4 comments

Comments

@scott-nz
Copy link

When duplicating a page that contains a user form block, the block is created on the new page but it contains no form fields.

Steps to reproduce:
Add user form block to a page
Add form fields to the form block
Publish Form and page
Duplicate page
Form block is created but contains no form fields

When duplicating a page, the content of other elemental blocks appears to be duplicated correctly

@robbieaverill
Copy link
Contributor

Can you please share the relevant module versions you’re using?

@scott-nz
Copy link
Author

Issue identified with following version
silverstripe-elemental-userforms: 2.1.2
silverstripe-elemental: 1.0.0

Same issue exists when using the following versions:
silverstripe-elemental-userforms: 3.0.x-dev, 3.0.0
silverstripe-elemental: 4.1.x-dev, 4.0.3
these versions were tested using https://github.com/silverstripe/cwp-recipe-kitchen-sink

@clarkepaul
Copy link

Pretty sure this is generic to most/all blocks types in that it doesn't carry things across.

@kinglozzer
Copy link

kinglozzer commented May 27, 2021

Just encountered this, the fields are duplicated in the database but they’re not assigned to the new block. $this->owner->ID is 0 when it attempts to clone the fields here:

https://github.com/silverstripe/silverstripe-userforms/blob/203e3749af71d40c52849d3e1e974618cf55fc50/code/Extension/UserFormFieldEditorExtension.php#L242

My very naïve workaround for now is this:

<?php

namespace App\Extensions\Elements;

use SilverStripe\Core\Extension;

class ElementFormExtension extends Extension
{
    public function onBeforeDuplicate()
    {
        $this->owner->write();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants