Project

General

Profile

Actions

Feature #77450

closed

Easier Validation handling inside initilize*Actions

Added by Tobias Braumann over 7 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2016-08-09
Due date:
% Done:

0%

Estimated time:
PHP Version:
7.0
Tags:
Complexity:
Sprint Focus:

Description

Half day is gone and i couldn't find any good solution for my problem without writing my own validator or ended up with a second model.

First i want to describe my problem here. This are my models:

My order has to address properties, one for shipping (mandatory) and one for the billing (optional). The address model has some mandatory fields. There is a checkbox to show the billing address. Everthing works out of the box if
the user need both addresses. But in the case the shipping address and the billing address are the same, he only has to fill out the first address fields.

I know i could write my own validator, but than i have to check all my address properties by my self, and i thought about a solution to turn off the validtor for the property billlingAddress when the checkbox is not set. And i think the best
place for the would be the initilize*Actions

There should be an easy way to do that, similar to the propertyMappingConfiguration.

Pseudocode inside an initilize*Action:

if ($this->arguments->hasArgument('order') && $showBillingAddress === TRUE) {
    $orderValidator = $this->arguments->getArgument('order')->getValidator();
    $orderValidator->forProperty('billingAddress')->removeValidator() 
        // or $orderValidator->skipValidationForProperty('billingAddress')
}

By the way, this would give us a more dynamic way for validation for specific actions, without the need to write a own model validator for smaller problems like this. Or did I overlooked anything?


Files

order .png (47.4 KB) order .png Tobias Braumann, 2016-08-09 10:55
Actions

Also available in: Atom PDF