-
Notifications
You must be signed in to change notification settings - Fork 96
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
NEW Show icons on tabs with invalid form field values #1111
NEW Show icons on tabs with invalid form field values #1111
Conversation
645873e
to
9842494
Compare
9842494
to
a516678
Compare
a516678
to
60eaece
Compare
Test only multi-tab page type to be added to frameworktest in a subsequent pull-request and can be used for manual testing I'm not sure how to automatically test the 2 validate() functions, particularly the There are 3 failed validation scenarios:
<?php
namespace {
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\TextField;
class MultiTabPage extends SiteTree
{
private static $db = [
'SecondTabFirstField' => 'Varchar(50)',
'ThirdTabFirstField' => 'Varchar(50)',
'ThirdTabSecondField' => 'Varchar(50)',
'FourthTabFirstField' => 'Varchar(50)',
'SettingsTabFirstField' => 'Varchar(50)',
];
private static $has_one = [];
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Second", TextField::create("SecondTabFirstField"));
$fields->addFieldToTab("Root.Third", TextField::create("ThirdTabFirstField"));
$fields->addFieldToTab("Root.Third", TextField::create("ThirdTabSecondField"));
$fields->addFieldToTab("Root.Fourth", TextField::create("FourthTabFirstField"));
return $fields;
}
public function getSettingsFields()
{
$fields = parent::getSettingsFields();
$fields->addFieldToTab("Root.Settings", TextField::create('SettingsTabFirstField'));
return $fields;
}
public function getCMSValidator()
{
return new RequiredFields([
'ThirdTabFirstField',
'FourthTabFirstField',
'SettingsTabFirstField'
]);
}
public function validate()
{
$result = parent::validate();
// validation error on speicific form field - uncomment to test
$result->addFieldError('SecondTabFirstField', 'This field cannot exist.');
// general validation error on form - uncomment to test
// try testing with `->addFieldError` line above commented out and not comment out
$result->addError('This page cannot exist.');
return $result;
}
}
} |
60eaece
to
bab66e1
Compare
Behat test should look something like this. It should be in the Will also need to create a function probably in We should discuss before implementation if we even want to do this at all.
|
bab66e1
to
d5fae61
Compare
aee68d5
to
b54b057
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some feedback on the implementation; also found another edgecase - if a DataObject::validate()
method triggers addFieldError()
but not addError()
, none of the new behaviour triggers.
I've also noticed that addMessage
and addFieldMessage
don't render at all, but this seems to be an existing bug, so we can raise a separate issue for that.
client/src/styles/legacy/_style.scss
Outdated
align-self: flex-start; | ||
margin-top: 12px; | ||
margin-left: -4px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using flex, I suggest taking this icon out of the standard flow, as the current approach pushes away the tab to the right.
align-self: flex-start; | |
margin-top: 12px; | |
margin-left: -4px; | |
position: relative; | |
top: 12px; | |
right: 4px; |
(You should also be able to drop out the other flex rules above.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the horizontally moving tabs is actually intentional, otherwise you end up with not much whitespace between tabs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I peer reviewed this yesterday with @Cheddam and we would like to keep the spacing between tabs consistent as seen per designs. I didn't notice this in our initial design review together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
b54b057
to
5701629
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more minor items - once these are addressed (along with the existing styling feedback) we should be good to merge.
5701629
to
ba2aad5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from a UX POV
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Enhancement for #1109
Youtube video demo
Used to communicate which tabs have invalid form field values
Design
Design elements implemented:
Design elements not implemented:
TODO before peer review:
TODO testing
TODO before closing: