Exemple #1
0
 public static function fillFromModelAttribute($formSlug, $modelAttributes)
 {
     $form = FormService::findBySlug($formSlug);
     $fieldsMap = [];
     if (isset($form)) {
         $formFields = $form->getFieldsMap();
         foreach ($formFields as $key => $formField) {
             // Convert CheckBox csv to array
             if ($formField->isCheckboxGroup()) {
                 $this->{$fieldName} = split("/,/", $formField->value);
             }
             // Ignore passwords
             if (!$formField->isPasswordField()) {
                 $formField->value = $modelAttributes[$key]->value;
             }
             $fieldsMap[$formField->name] = $formField;
         }
     }
     return $fieldsMap;
 }