Skip to content

Beautiful Open-Source Form Builder

D4310 new input section (#427)

Julien Nahum0cb7f86d93ed
diff --git a/app/Http/Requests/AnswerFormRequest.php b/app/Http/Requests/AnswerFormRequest.php
index 3ba1caae7..4057c9bc5 100644
--- a/app/Http/Requests/AnswerFormRequest.php
+++ b/app/Http/Requests/AnswerFormRequest.php
@@ -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;
}
diff --git a/app/Service/Forms/FormLogicConditionChecker.php b/app/Service/Forms/FormLogicConditionChecker.php
index a7573859b..dac6a900a 100644
--- a/app/Service/Forms/FormLogicConditionChecker.php
+++ b/app/Service/Forms/FormLogicConditionChecker.php
@@ -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