Skip to content

Commit

Permalink
CompatForm: Use attribute cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
Timm Ortloff committed Feb 17, 2023
1 parent 84be022 commit e6393f3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Compat/CompatForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,15 @@ public function hasDefaultElementDecorator()
*/
public function duplicateSubmitButton(FormSubmitElement $originalSubmitButton): SubmitElement
{
$attributes = array_reduce(
$originalSubmitButton->getAttributes()->getIterator()->getArrayCopy(),
function ($carry, $attribute) {
$carry[$attribute->getName()] = $attribute->getValue();

return $carry;
},
[]
);
$attributes['class'] = 'primary-submit-btn-duplicate';
$attributes = (clone $originalSubmitButton->getAttributes())
->set('class', 'primary-submit-btn-duplicate');
$attributes->remove('id');

$submit = (new SubmitElement($originalSubmitButton->getName(), $attributes))
->setValue($originalSubmitButton->getValue());

$attributes->registerAttributeCallback('name', [$submit, 'getNameAttribute']);

return $submit;
}
}

0 comments on commit e6393f3

Please sign in to comment.