Fixes in modelforms
This commit is contained in:
parent
a30676de2f
commit
3dcd035e4c
3 changed files with 28 additions and 5 deletions
|
|
@ -30,6 +30,7 @@ class BaseForm {
|
||||||
public $field;
|
public $field;
|
||||||
public $comment_form='';
|
public $comment_form='';
|
||||||
public $code_error=0;
|
public $code_error=0;
|
||||||
|
public $error=0;
|
||||||
public $txt_error='';
|
public $txt_error='';
|
||||||
public $extra_param='';
|
public $extra_param='';
|
||||||
public $parameters=[];
|
public $parameters=[];
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace PhangoApp\PhaForms\Forms;
|
namespace PhangoApp\PhaForms\Forms;
|
||||||
|
|
||||||
use PhangoApp\PhaModels\Forms\BaseForm;
|
use PhangoApp\PhaForms\Forms\BaseForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic class for create forms
|
* Basic class for create forms
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ class ModelForm {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->error_flag=1;
|
$form->error=1;
|
||||||
|
|
||||||
if($form->required==1)
|
if($form->required==1)
|
||||||
{
|
{
|
||||||
|
|
@ -339,6 +339,28 @@ class ModelForm {
|
||||||
return [$arr_form, false];
|
return [$arr_form, false];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get errors from forms array
|
||||||
|
*
|
||||||
|
* With this method you can extract an array with errors from forms array
|
||||||
|
*
|
||||||
|
* @param array $arr_form is an array of ModelForms. The key of each item is the name of the ModelForm item.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static public function get_errors($arr_form) {
|
||||||
|
|
||||||
|
$errors=[];
|
||||||
|
|
||||||
|
foreach($arr_form as $form) {
|
||||||
|
|
||||||
|
$errors[$form->name]=$form->std_error;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -455,13 +477,13 @@ class ModelForm {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static public function show_form($arr_form, $post, $pass_values=false, $check_values=false, $keys_form=[])
|
static public function show_form($arr_form, $post, $pass_values=false, $check_values=false, $keys_form=[], $show_error=1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($pass_values)
|
if($pass_values)
|
||||||
{
|
{
|
||||||
|
|
||||||
$arr_form=ModelForm::set_values_form($arr_form, $post, $show_error=1);
|
$arr_form=ModelForm::set_values_form($arr_form, $post, $show_error);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -522,7 +544,7 @@ class ModelForm {
|
||||||
$label_class=$arr_form[$field]->label_class;
|
$label_class=$arr_form[$field]->label_class;
|
||||||
?>
|
?>
|
||||||
<p>
|
<p>
|
||||||
<label class="<?php echo $label_class; ?>"><?php echo ucfirst(str_replace('_', ' ', $arr_form[$field]->label) );?> <?php echo $arr_required[$arr_form[$field]->required]; ?> <span class="error"><?php echo $arr_form[$field]->std_error; ?></span>: </label>
|
<label class="<?php echo $label_class; ?>"><?php echo ucfirst(str_replace('_', ' ', $arr_form[$field]->label) );?> <?php echo $arr_required[$arr_form[$field]->required]; ?> <span class="error" id="<?=$field;?>_error"><?php echo $arr_form[$field]->std_error; ?></span>: </label>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $arr_form[$field]->form();
|
echo $arr_form[$field]->form();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue