-
Notifications
You must be signed in to change notification settings - Fork 116
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
Only a single RequiredFields validation message shows at a time #1187
Comments
I can't replicate, seems like it works correctly on 5.x-dev Using the following code for my content block app/src/MyBlock.php <?php
use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Assets\Image;
class MyBlock extends BaseElement
{
private static $db = [
'MyField' => 'Varchar',
'MyOtherField' => 'Varchar',
];
private static $has_one = [
'MyImage' => Image::class,
'MyOtherImage' => Image::class,
];
private static $table_name = 'MyBlock';
private static $singular_name = 'My Block';
private static $plural_name = 'My Blocks';
private static $description = 'This is my block';
private static $icon = 'font-icon-block-content';
public function getType()
{
return 'My Block';
}
public function getCMSCompositeValidator(): CompositeValidator
{
return CompositeValidator::create([new RequiredFields([
'MyField',
'MyOtherField',
'MyImage',
'MyOtherImage'
])]);
}
} app/src/MyModelAdmin.php <?php
use SilverStripe\Admin\ModelAdmin;
class MyBlockAdmin extends ModelAdmin
{
private static $url_segment = 'MyBlockAdmin';
private static $menu_title = 'My block admin';
private static $managed_models = [
MyBlock::class,
];
} When I page save I get this When I edit from a ModelAdmin I get this When I inline save I get this, the reason only the textfields have validation message is because there's client side validation that happens before sending it to the server, though it's not active on the upload fields When I fill in the textfields with values and submit, I get back multiple validation warnings |
@GuySartorelli wants to have a second look. |
The problem I was seeing only happens if |
Split off from #1178 (review)
Elemental inline-editable blocks when you save the page, only one required field validation message appears at a time.
So if I don't enter any data I only get told about the title, then I add a title and I'm told about the image, then I add an image and I'm told about the page.
The HTTP response does have all three validation errors at the same time
Acceptance criteria
The text was updated successfully, but these errors were encountered: