Skip to content

Commit

Permalink
Update FormsManager.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed May 16, 2022
1 parent e5a111e commit 4ac2a43
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/MicroweberPackages/Form/FormsManager.php
Expand Up @@ -360,24 +360,24 @@ public function post($params)

$more = $this->app->fields_manager->get($get_fields);

$fieldRulesSettings = [];
$fieldsValidation = [];

$cfToSave = array();
if (!empty($more)) {
foreach ($more as $item) {

$appendToRequired = false;
$fieldsValidation[$item['name_key']][] = 'max:500';

$appendToRequired = false;
if ($item['required'] == 1) {
$appendToRequired = true;
}
if (isset($item['type']) && $item['type'] == 'upload') {
$appendToRequired = false;
}

if ($appendToRequired) {
$requiredFields[$item['name_key']] = [
'required'
];
$fieldsValidation[$item['name_key']][] = 'required';
}

if (isset($item['name'])) {
Expand Down Expand Up @@ -453,9 +453,9 @@ public function post($params)
}

$validationErrorsReturn = [];
if (!empty($requiredFields)) {
if (!empty($fieldsValidation)) {

$validator = Validator::make($params, $requiredFields);
$validator = Validator::make($params, $fieldsValidation);
if ($validator->fails()) {
$validatorMessages = false;
foreach ($validator->messages()->toArray() as $inputFieldErros) {
Expand Down

0 comments on commit 4ac2a43

Please sign in to comment.