Skip to content

Commit af6947c

Browse files
committed
fields = false is not working, skip dirty check with a custom class
1 parent 94a8c19 commit af6947c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

demos/_includes/DemoActionsUtil.php

+13
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ public static function setupDemoActions(Country $country): void
7171
]);
7272

7373
$country->addUserAction('edit_iso', [
74+
AnonymousClassNameCache::get_class(fn () => new class() extends UserAction {
75+
protected function validateBeforeExecute(): void
76+
{
77+
// call parent but skip dirty fields check for data-action/factory-view.php demo
78+
$fieldOrig = $this->fields;
79+
$this->fields = false;
80+
try {
81+
parent::validateBeforeExecute();
82+
} finally {
83+
$this->fields = $fieldOrig;
84+
}
85+
}
86+
}),
7487
'caption' => 'Edit ISO3',
7588
'description' => function (UserAction $action) {
7689
return 'Edit ISO3 for country: ' /* TODO . $action->getEntity()->getTitle() */;

demos/data-action/factory-view.php

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ protected function getCardButton(Model\UserAction $action)
6262
foreach ($country->getModel()->getUserActions() as $action) {
6363
$showActions = ['callback', 'preview', 'edit_argument', 'edit_argument_prev', 'edit_iso', 'confirm', 'multi_step'];
6464
if (in_array($action->shortName, $showActions, true)) {
65-
$action->fields = false; // disable dirty check for Behat
6665
$cardActions->addClickAction($action);
6766
}
6867
}

0 commit comments

Comments
 (0)