Skip to content

Commit f3f7cfd

Browse files
authored
Merge pull request #1268 from magento/1226-delete-button-visible
1226: fixed issue with visible delete button in the new entity form
2 parents a390ffa + 14674c5 commit f3f7cfd

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
99
### Fixed
1010

1111
- Throwable: Stub index points to a file without PSI [#1232](https://github.com/magento/magento2-phpstorm-plugin/pull/1232)
12+
- Create an entity - delete button is displayed in a new entity form [#1268](https://github.com/magento/magento2-phpstorm-plugin/pull/1268)
1213

1314
## 5.0.0
1415

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ 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+
28+
#end
2329
return $this->wrapButtonSettings(
2430
'${LABEL}',
2531
'${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.getButtonType().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->getBookId()) {
21+
return [];
22+
}
23+
2024
return $this->wrapButtonSettings(
2125
'Delete',
2226
'delete',

0 commit comments

Comments
 (0)