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

Validation icon on form tab #1109

Closed
4 tasks done
brynwhyman opened this issue Sep 17, 2020 · 2 comments · Fixed by #1111
Closed
4 tasks done

Validation icon on form tab #1109

brynwhyman opened this issue Sep 17, 2020 · 2 comments · Fixed by #1111

Comments

@brynwhyman
Copy link

brynwhyman commented Sep 17, 2020

Overview

There's currently an open enhancement to add better handling to validation messages outside of a form tab that a CMS user has in focus, see: Validation messages for hidden tabs

Some early investigation into that enhancement has found that there's probably some regressed behaviour at play.

This issue aims to look at a more immediate fix utilising some of the code that's appeared to regress, with the addition of the icon indicators outlined in Validation messages for hidden tabs.

Acceptance criteria

  • When a validation error happens in a child tab (i.e. Content > 'Custom-tab') I can clearly identify the tab that it is contained in
  • Focus is retained on the form in view when the save was attempted and I am not redirected to the validation error

Notes

Designs

Patch designs
CMS Design System - Validation errors future state

PRs

@brynwhyman
Copy link
Author

Found this issue while looking at this: #1110

@Cheddam
Copy link
Member

Cheddam commented Sep 21, 2020

I tested the related PR (#1111) using the DataObject::validate() method, and found that it would render errors on fields, but not top-level errors / messages, and the tab icons did not render.

Sample code
class HomePage extends BaseHomePage
{
    private static $db = [
        'ExampleField' => 'Varchar',
    ];
    
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        
        $fields->addFieldToTab('Root.Test', TextField::create('ExampleField', 'Example Field'));
        
        return $fields;
    }
    
    public function validate()
    {
        $validation = parent::validate();
        
        // Just return a validation error every time
        $validation->addFieldError('ExampleField', 'This field cannot exist.');

        // Never renders :(
        $validation->addError('This page cannot exist.');
        
        return $validation;
    }
}

@Cheddam Cheddam assigned emteknetnz and unassigned Cheddam Sep 22, 2020
@emteknetnz emteknetnz assigned Cheddam and unassigned emteknetnz Sep 22, 2020
@Cheddam Cheddam assigned emteknetnz and unassigned Cheddam Sep 22, 2020
@emteknetnz emteknetnz assigned Cheddam and unassigned emteknetnz Sep 23, 2020
@brynwhyman brynwhyman assigned emteknetnz and unassigned Cheddam Sep 23, 2020
@emteknetnz emteknetnz assigned dnsl48 and unassigned emteknetnz Sep 24, 2020
@dnsl48 dnsl48 assigned emteknetnz and unassigned dnsl48 Sep 24, 2020
@emteknetnz emteknetnz removed their assignment Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants