Multiple fixes in forms
This commit is contained in:
parent
3b85435367
commit
673d85a226
8 changed files with 131 additions and 19 deletions
|
|
@ -40,7 +40,7 @@ class BaseForm {
|
|||
public function form()
|
||||
{
|
||||
|
||||
return '<input type="'.$this->type.'" class="'.$this->css.'" name="'.$this->name.'" value="'.$this->setform($this->default_value).'">';
|
||||
return '<input type="'.$this->type.'" id="'.$this->name.'_field_form" class="'.$this->css.'" name="'.$this->name.'" value="'.$this->setform($this->default_value).'">';
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class DateForm extends \PhangoApp\PhaModels\Forms\BaseForm {
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
$value=PhaTime\DateTime::gmt_to_local($value);
|
||||
|
||||
list($year, $month, $day, $hour, $minute, $second)=PhaTime\DateTime::format_timedata($value);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class SelectForm extends BaseForm{
|
|||
ob_start();
|
||||
|
||||
?>
|
||||
<select name="<?php echo $this->name; ?>">
|
||||
<select name="<?php echo $this->name; ?>" id="<?php echo $this->name; ?>_field_form">
|
||||
<?php
|
||||
|
||||
foreach($this->arr_select as $value => $select)
|
||||
|
|
|
|||
99
src/Forms/SelectModelFormByOrder.php
Normal file
99
src/Forms/SelectModelFormByOrder.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace PhangoApp\PhaModels\Forms;
|
||||
|
||||
use PhangoApp\PhaModels\Webmodel;
|
||||
use PhangoApp\PhaModels\Forms\SelectForm;
|
||||
use PhangoApp\PhaI18n\I18n;
|
||||
|
||||
class SelectModelFormByOrder extends SelectForm {
|
||||
|
||||
public $model_name;
|
||||
public $identifier_field;
|
||||
public $field_parent;
|
||||
|
||||
public function __construct($name, $value, $model, $identifier_field, $field_parent, $where=['WHERE 1=1', []], $null_yes=1)
|
||||
{
|
||||
|
||||
parent::__construct($name, $value);
|
||||
|
||||
$this->model=$model;
|
||||
|
||||
$this->identifier_field=$identifier_field;
|
||||
|
||||
$this->field_parent=$field_parent;
|
||||
|
||||
$this->where=$where;
|
||||
|
||||
$this->null_yes=$null_yes;
|
||||
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
|
||||
//Need here same thing that selectmodelform...
|
||||
|
||||
$arr_model=array($this->default_value);
|
||||
|
||||
if($this->null_yes==1)
|
||||
{
|
||||
|
||||
$this->arr_select[0]=I18n::lang('common', 'no_element_chosen', 'No element chosen');
|
||||
|
||||
}
|
||||
|
||||
$arr_elements=array();
|
||||
|
||||
$query=$this->model->select([$this->model->idmodel, $this->identifier_field, $this->field_parent]);
|
||||
|
||||
while($arr_field=$this->model->fetch_array($query))
|
||||
{
|
||||
|
||||
$idparent=$arr_field[$this->field_parent];
|
||||
|
||||
$element_model=$this->model->components[$this->identifier_field]->show_formatted($arr_field[ $this->identifier_field ]);
|
||||
|
||||
$arr_elements[$idparent][]=array($element_model, $arr_field[ $this->model->idmodel ]);
|
||||
|
||||
}
|
||||
|
||||
$this->arr_select=$this->recursive_list_select($arr_elements, 0, $this->arr_select, '');
|
||||
|
||||
|
||||
return parent::form();
|
||||
|
||||
}
|
||||
|
||||
public function recursive_list_select($arr_elements, $element_id, $arr_result, $separator)
|
||||
{
|
||||
|
||||
$separator.=$separator;
|
||||
|
||||
if(isset($arr_elements[$element_id]))
|
||||
{
|
||||
|
||||
foreach($arr_elements[$element_id] as $element)
|
||||
{
|
||||
|
||||
$arr_result[$element[1]]=$separator.$element[0];
|
||||
//$arr_result[]=$element[1];
|
||||
|
||||
if( isset($arr_elements[$element[1]] ) )
|
||||
{
|
||||
|
||||
$arr_result=$this->recursive_list_select($arr_elements, $element[1], $arr_result, $separator.'--');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $arr_result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue