Fixes in forms

This commit is contained in:
Antonio de la Rosa 2016-02-19 03:22:01 +01:00
parent 0e0adcb05f
commit 1cddd12e93
8 changed files with 57 additions and 21 deletions

View file

@ -13,6 +13,7 @@ namespace PhangoApp\PhaModels\CoreFields;
use PhangoApp\PhaI18n\I18n; use PhangoApp\PhaI18n\I18n;
use PhangoApp\PhaModels\Forms\MultiLangForm; use PhangoApp\PhaModels\Forms\MultiLangForm;
use PhangoApp\PhaModels\Forms\TextForm;
use PhangoApp\PhaModels\CoreFields\SlugifyField; use PhangoApp\PhaModels\CoreFields\SlugifyField;
/** /**
@ -39,6 +40,7 @@ class I18nField extends PhangoField {
{ {
$this->type_field=&$type_field; $this->type_field=&$type_field;
$this->parameters=[];
} }

View file

@ -63,11 +63,14 @@ class ImageField extends PhangoField {
//Check the image for delete. //Check the image for delete.
//This field is used only for a row //This field is used only for a row
//echo $this->model_instance->conditions; die;
$old_reset=Webmodel::$model[$this->name_model]->reset_conditions; $old_reset=Webmodel::$model[$this->name_model]->reset_conditions;
Webmodel::$model[$this->name_model]->reset_conditions=0; Webmodel::$model[$this->name_model]->reset_conditions=0;
$old_image=Webmodel::$model[$this->name_model]->select_a_row_where(array($this->name_component), 1)[$this->name_component]; $old_image=Webmodel::$model[$this->name_model]->select_a_row_where(array($this->name_component), 1)[$this->name_component];
Webmodel::$model[$this->name_model]->reset_conditions=$old_reset; Webmodel::$model[$this->name_model]->reset_conditions=$old_reset;
} }
if(isset($_FILES[$file_name]['tmp_name'])) if(isset($_FILES[$file_name]['tmp_name']))
@ -76,7 +79,6 @@ class ImageField extends PhangoField {
if(trim($_FILES[$file_name]['tmp_name'])!=='') if(trim($_FILES[$file_name]['tmp_name'])!=='')
{ {
$name_image=$_FILES[$file_name]['name']; $name_image=$_FILES[$file_name]['name'];
if($this->prefix_id) if($this->prefix_id)

View file

@ -1,6 +1,8 @@
<?php <?php
namespace PhangoApp\PhaModels\CoreFields; namespace PhangoApp\PhaModels\CoreFields;
use PhangoApp\PhaI18n\I18n;
use PhangoApp\PhaModels\Webmodel;
/** This class can be used for create orders or searchs in mysql if you need other thing distinct to default search of default order (default order don't work fine with serializefields how i18nfield). The programmer have the responsability of update this fields via update or insert method. /** This class can be used for create orders or searchs in mysql if you need other thing distinct to default search of default order (default order don't work fine with serializefields how i18nfield). The programmer have the responsability of update this fields via update or insert method.
* *
@ -39,10 +41,10 @@ class SlugifyField extends CharField {
static function add_slugify_i18n_fields($model_name, $field) static function add_slugify_i18n_fields($model_name, $field)
{ {
foreach(PhangoVar::$arr_i18n as $lang_field) foreach(I18n::$arr_i18n as $lang_field)
{ {
PhangoVar::$model[$model_name]->components[$field.'_'.$lang_field]=new SlugifyField(); Webmodel::$model[$model_name]->components[$field.'_'.$lang_field]=new SlugifyField();
} }

View file

@ -12,7 +12,6 @@ class TextField extends PhangoField {
public $value=""; public $value="";
public $label=""; public $label="";
public $required=0; public $required=0;
public $form="TextAreaForm";
public $quot_open='\''; public $quot_open='\'';
public $quot_close='\''; public $quot_close='\'';
public $std_error=''; public $std_error='';
@ -22,7 +21,7 @@ class TextField extends PhangoField {
function __construct($multilang=0) function __construct($multilang=0)
{ {
$this->form='PhangoApp\PhaModels\Forms\BaseForm'; $this->form='PhangoApp\PhaModels\Forms\TextAreaForm';
$this->multilang=$multilang; $this->multilang=$multilang;
} }

View file

@ -12,7 +12,6 @@ class TextHTMLField extends PhangoField {
public $value=""; public $value="";
public $label=""; public $label="";
public $required=0; public $required=0;
public $form="TextAreaForm";
public $quot_open='\''; public $quot_open='\'';
public $quot_close='\''; public $quot_close='\'';
public $std_error=''; public $std_error='';
@ -25,7 +24,7 @@ class TextHTMLField extends PhangoField {
function __construct($multilang=0) function __construct($multilang=0)
{ {
$this->form='PhangoApp\PhaModels\Forms\BaseForm'; $this->form='PhangoApp\PhaModels\Forms\TextAreaEditor';
$this->set_safe_html_tags(); $this->set_safe_html_tags();

View file

@ -11,13 +11,20 @@ class MultiLangForm extends BaseForm{
public $type_form; public $type_form;
public function __construct($name, $value, $type_form='PhangoApp\PhaModels\Forms\BaseForm') public function __construct($name, $value, $form_class='')
{ {
$this->type_form=new $type_form($name, $value);
parent::__construct($name, $value); parent::__construct($name, $value);
if($form_class=='')
{
$form_class=new BaseForm($name, $value);
}
$this->type_form=&$form_class;
} }
public function form() public function form()

View file

@ -0,0 +1,23 @@
<?php
namespace PhangoApp\PhaModels\Forms;
use PhangoApp\PhaModels\Forms\BaseForm;
use PhangoApp\PhaUtils\Utils;
use PhangoApp\PhaView\View;
use PhangoApp\PhaRouter\Routes;
use PhangoApp\PhaI18n\I18n;
class TextAreaForm extends BaseForm {
public function form()
{
?>
<p><textarea class="tinymce_editor" name="<?php echo $this->name; ?>"><?php echo $this->setform($this->default_value); ?></textarea></p>
<?php
}
}
?>

View file

@ -950,13 +950,6 @@ class Webmodel {
$conditions=trim($this->conditions.' '.$this->order_by.' '.$this->limit); $conditions=trim($this->conditions.' '.$this->order_by.' '.$this->limit);
if($this->reset_conditions==1)
{
$this->reset_conditions();
}
//Make conversion from post //Make conversion from post
//Check if minimal fields are fill and if fields exists in components. //Check if minimal fields are fill and if fields exists in components.
@ -1031,6 +1024,13 @@ class Webmodel {
} }
}
if($this->reset_conditions==1)
{
$this->reset_conditions();
} }
//Create the query.. //Create the query..
@ -2046,9 +2046,11 @@ class Webmodel {
//$this->forms[$component_name]=new $form_class($component_name, $component->value, $component->parameters); //$this->forms[$component_name]=new $form_class($component_name, $component->value, $component->parameters);
$rc=new \ReflectionClass($form_class); $rc=new \ReflectionClass($form_class);
array_unshift($component->parameters, $component_name, $component->value); $parameters=$component->parameters;
$this->forms[$component_name]=$rc->newInstanceArgs($component->parameters); array_unshift($parameters, $component_name, $component->value);
$this->forms[$component_name]=$rc->newInstanceArgs($parameters);
$type_class=get_class($this->forms[$component_name]); $type_class=get_class($this->forms[$component_name]);