Skip to content

Commit

Permalink
New event so more validation classes can be added on the fly (#1490)
Browse files Browse the repository at this point in the history
* New event so more validation classes can be added on the fly

I ran into a situation where I needed more complex validation rules like min and max length for strings and min and max values for integers. Without this change, I cannot make it.

* Added missing cast to array

* resolve codestyle issue

* change arrays append to ArrayObject->append()

Co-authored-by: Daniel Fahlke <flyingmana@googlemail.com>
  • Loading branch information
woutersamaey and Flyingmana committed Jan 8, 2023
1 parent 8a60871 commit a22d834
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,21 @@ public function isVisible()
*/
public function getClass()
{
$out = [];
$out = new ArrayObject();
$out[] = $this->getAttribute()->getFrontendClass();
if ($this->getAttribute()->getIsRequired()) {
$out[] = 'required-entry';
$out->append('required-entry');
}

$inputRuleClass = $this->_getInputValidateClass();
if ($inputRuleClass) {
$out[] = $inputRuleClass;
$out->append($inputRuleClass);
}

Mage::dispatchEvent('eav_entity_attribute_frontend_get_class', ['classes' => $out, 'attribute' => $this->getAttribute()]);

if (!empty($out)) {
$out = implode(' ', $out);
$out = implode(' ', (array) $out);
} else {
$out = '';
}
Expand Down

0 comments on commit a22d834

Please sign in to comment.