Skip to content

Commit 9aefdea

Browse files
author
Vitaliy Boyko
committed
1226: fixed issue with visible delete button in the new entity form
1 parent eb4d524 commit 9aefdea

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

resources/fileTemplates/internal/Magento Form Button Block Class.php.ft

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class ${NAME} extends ${GENERIC_BUTTON} implements ${DATA_PROVIDER_TYPE}
2020
*/
2121
public function getButtonData(): array
2222
{
23+
#if (${GET_ID})
24+
if (!$this->${GET_ID}) {
25+
return [];
26+
}
27+
#end
2328
return $this->wrapButtonSettings(
2429
'${LABEL}',
2530
'${CLASS}',

src/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormButtonBlockGenerator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ protected void fillAttributes(final @NotNull Properties attributes) {
208208
attributes.setProperty("SORT_ORDER", String.valueOf(buttonTypeSettings.getSortOrder()));
209209
attributes.setProperty("ENTITY_NAME", Strings.toLowerCase(entityName));
210210
attributes.setProperty("ENTITY_ID", entityIdField);
211+
if (buttonData.getButtonClassName().equals(FormButtonBlockFile.TYPE_DELETE)) {
212+
attributes.setProperty("GET_ID", entityIdAccessor);
213+
}
211214

212215
attributes.setProperty("USES", PhpClassGeneratorUtil.formatUses(uses));
213216
}

testData/actions/generation/generator/FormButtonBlockGenerator/generateDeleteButtonBlock/DeleteBlock.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class DeleteBlock extends GenericButton implements ButtonProviderInterface
1717
*/
1818
public function getButtonData(): array
1919
{
20+
if (!$this->getAmazingId()) {
21+
return [];
22+
}
23+
2024
return $this->wrapButtonSettings(
2125
'Delete',
2226
'delete',

0 commit comments

Comments
 (0)