/** * Add editor config * * @param UiComponentInterface $column * @param string $frontendInput * @param array $validationRules * @param bool|false $isRequired * @return UiComponentInterface */ public function applyEditing(UiComponentInterface $column, $frontendInput, array $validationRules, $isRequired = false) { if (in_array($frontendInput, $this->editableFields)) { $config = $column->getConfiguration(); $editorType = $config['dataType']; if (isset($config['editor']) && is_string($config['editor'])) { $editorType = $config['editor']; } if (!(isset($config['editor']) && isset($config['editor']['editorType']))) { $config['editor'] = ['editorType' => $editorType]; } $validationRules = $this->validationRules->getValidationRules($isRequired, $validationRules); if (!empty($config['editor']['validation'])) { $validationRules = array_merge($config['editor']['validation'], $validationRules); } $config['editor']['validation'] = $validationRules; $column->setData('config', $config); } return $column; }
public function testGetValidationRulesWithOnlyRequiredRule() { $expectsRules = ['required-entry' => true]; $this->assertEquals($expectsRules, $this->validationRules->getValidationRules(true, [])); }