-
Notifications
You must be signed in to change notification settings - Fork 78
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
Duplicating form fields removes original field #336
Comments
@alexander-schranz This bug occurs because the duplicated block also includes the same I tried removing both fields in the I would appreciate any updates on this issue. |
I think we need adjust here something: https://github.com/sulu/SuluFormBundle/blob/2.5/Manager/FormManager.php#L313 + $fields = self::getValue($data, 'fields', []);
+ $existingIds = [];
+ $existingKeys = [];
+ foreach ($fields as &$fieldData) {
+ if (\in_array($field['id'] ?? null, $existingId) {
+ \unset($field['id']);
+ }
+ if (\in_array($field['key'] ?? null, $existingKeys) {
+ \unset($field['key']);
+ }
+
+ if (isset($field['id'])) {
+ $existingIds[] = $field['id'];
+ }
+
+ if (isset($field['key'])) {
+ $existingKeys[] = $field['key'];
+ }
+ }
- $reservedKeys = \array_column(self::getValue($data, 'fields', []), 'key');
+ $reservedKeys = \array_column($fields, 'key');
$counter = 0;
- foreach (self::getValue($data, 'fields', []) as $fieldData) {
+ foreach ($fields as $fieldData) { Then it should be correctly create a new field as |
@0xJas0n @jeroenmager1 please give #377 a try |
Actual Behavior
If you edit a Sulu form in the admin and click on the duplicate button of a form field, it deletes the original version of the form field the moment you hit the save button.
Expected Behavior
I expect that if i duplicate a form field both the original and the newly created form field keep existing after saving.
Steps to Reproduce
In a form click on the duplicate button of a form field. Click on the save button
The text was updated successfully, but these errors were encountered: