dnadesign / silverstripe-elemental-userforms

Adds a new element for usersforms
BSD 3-Clause "New" or "Revised" License
9 stars 16 forks source link

Form fields not created when duplicating a page #41

Open scott-nz opened 5 years ago

scott-nz commented 5 years ago

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 commented 5 years ago

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

scott-nz commented 5 years ago

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 commented 4 years ago

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

kinglozzer commented 3 years ago

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();
    }
}