D4310 new input section (#427)
* wip: validation condition input * form custom validation condition * Default message on form condition validation * field validation condition test * fix linting * update tests, add pass test * Polish UI * Re-order validation + fix logic issue * Move custom validation after default validation --------- Co-authored-by: Frank <csskfaves@gmail.com>
This commit is contained in:
parent
6673dff504
commit
0cb7f86d93
|
|
@ -87,11 +87,6 @@ class AnswerFormRequest extends FormRequest
|
|||
$rules[] = 'nullable';
|
||||
}
|
||||
|
||||
// User custom validation
|
||||
if(!(Str::of($property['type'])->startsWith('nf-')) && isset($property['validation'])) {
|
||||
$rules[] = (new CustomFieldValidationRule($property['validation'], $data));
|
||||
}
|
||||
|
||||
// Clean id to escape "."
|
||||
$propertyId = $property['id'];
|
||||
if (in_array($property['type'], ['multi_select'])) {
|
||||
|
|
@ -101,6 +96,11 @@ class AnswerFormRequest extends FormRequest
|
|||
$rules = array_merge($rules, $this->getPropertyRules($property));
|
||||
}
|
||||
|
||||
// User custom validation
|
||||
if(!(Str::of($property['type'])->startsWith('nf-')) && isset($property['validation'])) {
|
||||
$rules[] = (new CustomFieldValidationRule($property['validation'], $data));
|
||||
}
|
||||
|
||||
$this->requestRules[$propertyId] = $rules;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,10 @@ class FormLogicConditionChecker
|
|||
|
||||
private function checkContains($condition, $fieldValue): bool
|
||||
{
|
||||
return ($fieldValue && is_array($fieldValue)) ? in_array($condition['value'], $fieldValue) : false;
|
||||
if (is_array($fieldValue)) {
|
||||
return in_array($condition['value'], $fieldValue);
|
||||
}
|
||||
return \Str::contains($fieldValue, $condition['value']);
|
||||
}
|
||||
|
||||
private function checkListContains($condition, $fieldValue): bool
|
||||
|
|
|
|||
Loading…
Reference in New Issue