|
|
|
@ -43,6 +43,10 @@ final class use_io { |
|
|
|
public $input_var; |
|
|
|
public $input_var; |
|
|
|
public string $field_description; |
|
|
|
public string $field_description; |
|
|
|
public FORM_INPUT_TYPES $form_type; |
|
|
|
public FORM_INPUT_TYPES $form_type; |
|
|
|
|
|
|
|
public bool $show_label = true; |
|
|
|
|
|
|
|
public string $div_class = ""; |
|
|
|
|
|
|
|
public string $label_class = ""; |
|
|
|
|
|
|
|
public string $form_control_class = ""; |
|
|
|
public INPUTS $input_type; |
|
|
|
public INPUTS $input_type; |
|
|
|
public FIELD_FILTER $field_filter; |
|
|
|
public FIELD_FILTER $field_filter; |
|
|
|
public HTML_FLAG $escape_html; |
|
|
|
public HTML_FLAG $escape_html; |
|
|
|
@ -97,6 +101,43 @@ final class safer_io { |
|
|
|
protected function __construct() { |
|
|
|
protected function __construct() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function build_html(array $input): array { |
|
|
|
|
|
|
|
$html_output = []; |
|
|
|
|
|
|
|
$errors = []; |
|
|
|
|
|
|
|
$headers = []; |
|
|
|
|
|
|
|
$show_labels =[]; |
|
|
|
|
|
|
|
$form_type = []; |
|
|
|
|
|
|
|
$required = []; |
|
|
|
|
|
|
|
$classes = []; |
|
|
|
|
|
|
|
foreach(self::esv($input['html']) as $html) { |
|
|
|
|
|
|
|
$key = $html['name'] ?? ""; |
|
|
|
|
|
|
|
$html_output[$key] = $html['html']; |
|
|
|
|
|
|
|
$headers[$key] = $html['meta']['field_desc'][$key] ?? ""; |
|
|
|
|
|
|
|
$show_labels[$key] = $html['meta']['show_label'][$key] ?? true; |
|
|
|
|
|
|
|
$form_type[$key] = $html['meta']['form_type'][$key] ?? FORM_TYPE::text->value; |
|
|
|
|
|
|
|
$classes['label'][$key] = $html['meta']['label_class'] ?? ""; |
|
|
|
|
|
|
|
$classes['div'][$key] = $html['meta']['div_class'] ?? ""; |
|
|
|
|
|
|
|
$classes['ctrl'][$key] = $html['meta']['form_control_class'] ?? ""; |
|
|
|
|
|
|
|
$required[$key] = $html['meta']['required'][$key] ?? false; |
|
|
|
|
|
|
|
if (\CodeHydrater\common::get_count($html['errors'])) { |
|
|
|
|
|
|
|
$errors[$key] = $html['errors'][$key]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// dump($html); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
'div-class' => $input['classes']['div-class'] ?? "mb-3", |
|
|
|
|
|
|
|
'form-control-class' => $input['classes']['form-control-class'] ?? "", |
|
|
|
|
|
|
|
'label-class' => $input['classes']['label-class'] ?? "", |
|
|
|
|
|
|
|
'classes'=>$classes, |
|
|
|
|
|
|
|
'html'=>$html_output, |
|
|
|
|
|
|
|
'errors'=>$errors, |
|
|
|
|
|
|
|
'headers'=>$headers, |
|
|
|
|
|
|
|
'show_labels'=>$show_labels, |
|
|
|
|
|
|
|
'form_type'=>$form_type, |
|
|
|
|
|
|
|
'required'=>$required |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get raw data for inputs, to be used by filters |
|
|
|
* Get raw data for inputs, to be used by filters |
|
|
|
@ -484,6 +525,22 @@ final class safer_io { |
|
|
|
$meta['field_desc'][$input_field_name] = $a->field_description; |
|
|
|
$meta['field_desc'][$input_field_name] = $a->field_description; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($a->show_label)) { |
|
|
|
|
|
|
|
$meta['show_label'][$input_field_name] = $a->show_label; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($a->div_class)) { |
|
|
|
|
|
|
|
$meta['div_class'][$input_field_name] = $a->div_class; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($a->label_class)) { |
|
|
|
|
|
|
|
$meta['label_class'][$input_field_name] = $a->label_class; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($a->form_control_class)) { |
|
|
|
|
|
|
|
$meta['form_control_class'][$input_field_name] = $a->form_control_class; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isset($a->validation_rule)) { |
|
|
|
if (isset($a->validation_rule)) { |
|
|
|
if (str_contains($a->validation_rule, "required")) { |
|
|
|
if (str_contains($a->validation_rule, "required")) { |
|
|
|
$meta['required'][$input_field_name] = true; |
|
|
|
$meta['required'][$input_field_name] = true; |
|
|
|
|