Skip to content
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

Required fields are not checked on final step of Wizard #2156

Closed
pootedesu opened this issue Feb 2, 2024 · 2 comments · Fixed by #2193
Closed

Required fields are not checked on final step of Wizard #2156

pootedesu opened this issue Feb 2, 2024 · 2 comments · Fixed by #2193
Labels

Comments

@pootedesu
Copy link

pootedesu commented Feb 2, 2024

Expected Behavior
Clicking "Finish" on the final page of a Wizard will check all required fields and prompt for any blank fields before moving forward.

Actual Behavior
Clicking "Finish" displays the finish screen and ignores required fields.

<?php

declare(strict_types=1);

namespace Atk4\Ui\Demos;

use Atk4\Ui\Form;
use Atk4\Ui\Header;
use Atk4\Ui\Wizard;

/** @var App $app */
require_once __DIR__ . '/../init-app.php';

$wizard = Wizard::addTo($app);

$stepFx = static function (Wizard $wizard) {
    $form = Form::addTo($wizard);
    $form->addControl('city', [], ['required' => true]);
    $form->onSubmit(static function (Form $form) use ($wizard) {
        return $wizard->jsNext();
    });
};
$wizard->addStep(['Step 1'], $stepFx);
$wizard->addStep(['Step 2'], $stepFx);

$wizard->addFinish(static function (Wizard $wizard) {
    Header::addTo($wizard, ['Wizard completed']);
});
@mvorisek
Copy link
Member

mvorisek commented Feb 3, 2024

The bug is here: https://github.com/atk4/ui/blob/ca975df74c/src/Wizard.php#L145 - form is submitted only using the next button but not the finish button. Fix is easy, but Behat tests need to be coded...

@mvorisek
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants