Added SelectForm
This commit is contained in:
parent
7dbe80697e
commit
6a608f0389
2 changed files with 74 additions and 3 deletions
52
src/Forms/SelectForm.php
Normal file
52
src/Forms/SelectForm.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhangoApp\PhaModels\Forms;
|
||||||
|
|
||||||
|
use PhangoApp\PhaModels\Forms\BaseForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic class for create forms
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SelectForm extends BaseForm{
|
||||||
|
|
||||||
|
public $arr_select=array();
|
||||||
|
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
|
||||||
|
//return '<input type="password" class="'.$this->css.'" name="'.$this->name.'" value="">';
|
||||||
|
$arr_selected[$this->default_value]=' selected';
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<select name="<?php echo $this->name; ?>">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach($this->arr_select as $value => $select)
|
||||||
|
{
|
||||||
|
|
||||||
|
settype($arr_selected[$value], 'string');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $value; ?>"<?php echo $arr_selected[$value]; ?>><?php echo $select; ?></option>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$input=ob_get_contents();
|
||||||
|
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -393,18 +393,18 @@ class ModelForm {
|
||||||
if($arr_form[$name_field]->field->std_error!='' && $show_error==1)
|
if($arr_form[$name_field]->field->std_error!='' && $show_error==1)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*if($arr_form[$name_field]->std_error!='')
|
if($arr_form[$name_field]->std_error!='')
|
||||||
{
|
{
|
||||||
|
|
||||||
$arr_form[$name_field]->std_error=$arr_form[$name_field]->txt_error;
|
$arr_form[$name_field]->std_error=$arr_form[$name_field]->txt_error;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else*/
|
else
|
||||||
if($arr_form[$name_field]->std_error=='')
|
if($arr_form[$name_field]->std_error=='')
|
||||||
{
|
{
|
||||||
|
|
||||||
$arr_form[$name_field]->std_error=$arr_form[$name_field]->type->std_error;
|
$arr_form[$name_field]->std_error=$arr_form[$name_field]->field->std_error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -413,6 +413,7 @@ class ModelForm {
|
||||||
//Set value for ModelForm to $value
|
//Set value for ModelForm to $value
|
||||||
|
|
||||||
$arr_form[$name_field]->default_value=$value;
|
$arr_form[$name_field]->default_value=$value;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -426,6 +427,24 @@ class ModelForm {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function pass_errors_to_form($model)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach(array_keys($model->components) as $key)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isset($model->forms[$key]))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$model->forms[$key]->field->std_error=$model->components[$key]->std_error;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue