Fixes on fields for new behaviour

This commit is contained in:
Antonio de la Rosa 2015-08-28 05:24:58 +02:00
parent 2a342ad9f9
commit 890704010b
21 changed files with 78 additions and 36 deletions

View file

@ -24,7 +24,7 @@ class BooleanField extends PhangoField {
{
$this->size=1;
$this->form='PhangoApp\PhaModels\CoreForms::SelectForm';
$this->form=public $form='PhangoApp\PhaModels\Forms\SelectForm';
}

View file

@ -31,7 +31,7 @@ class CharField extends PhangoField {
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::TextForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
}

View file

@ -3,6 +3,7 @@
namespace PhangoApp\PhaModels\CoreFields;
use PhangoApp\PhaUtils\Utils;
use PhangoApp\PhaI18n\I18n;
use PhangoApp\PhaModels\Forms\SelectForm;
/**
*
@ -14,7 +15,6 @@ class ChoiceField extends PhangoField {
public $value=0;
public $label="";
public $required=0;
public $form="";
public $quot_open='\'';
public $quot_close='\'';
public $std_error='';
@ -22,18 +22,18 @@ class ChoiceField extends PhangoField {
public $arr_values=array();
public $arr_formatted=array();
public $default_value='';
public $form='PhangoApp\PhaModels\Forms\SelectForm';
function __construct($size=11, $type='integer', $arr_values=array(), $default_value='')
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::SelectForm';
$this->type=$type;
$this->arr_values=$arr_values;
$this->default_value=$default_value;
$this->arr_formatted['']='';
$this->arr_formatted['']=I18n::lang('common', 'none_selected', 'None selected');
foreach($arr_values as $value)
{
@ -119,11 +119,13 @@ class ChoiceField extends PhangoField {
public function show_formatted($value)
{
$this->restart_formatted();
return $this->arr_formatted[$value];
}
/*
function get_parameters_default()
{
@ -145,13 +147,26 @@ class ChoiceField extends PhangoField {
else
{
$arr_values=array(0, 'Option 1', 0, 'Option 2', 1);
$arr_values=array(0 => 'Option 1', 1 => 'Option 2');
}
return array($this->name_component, '', $arr_values);
}
}*/
/*
public function create_form()
{
$form=new SelectForm($this->name_component, $this->value);
$form->default_value=$this->default_value;
$form->required=$this->required;
$form->label=$this->label;
$form->arr_select=$this->arr_formatted;
return $form;
}*/
}

View file

@ -23,7 +23,7 @@ class DateField extends PhangoField {
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::DateForm';
$this->form='PhangoApp\PhaModels\CoreForms\DateForm';
}

View file

@ -22,7 +22,7 @@ class DoubleField extends PhangoField {
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::TextForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
}

View file

@ -12,7 +12,7 @@ class EmailField extends PhangoField {
public $size=200;
public $value="";
public $label="";
public $form="PhangoApp\PhaModels\CoreForms::TextForm";
public $form='PhangoApp\PhaModels\Forms\BaseForm';
public $class="";
public $required=0;
public $quot_open='\'';

View file

@ -12,7 +12,7 @@ class FileField extends PhangoField {
public $value="";
public $label="";
public $required=0;
public $form="PhangoApp\PhaModels\CoreForms::FileForm";
public $form='PhangoApp\PhaModels\Forms\BaseForm';
public $name_file="";
public $path="";
public $url_path="";

View file

@ -28,7 +28,7 @@ class ForeignKeyField extends IntegerField{
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::SelectForm';
$this->form='PhangoApp\PhaModels\Forms\SelectForm';
$this->related_model=&$related_model;
$this->container_model=$this->related_model->name;
//Fields obtained from related_model if you make a query...
@ -76,7 +76,9 @@ class ForeignKeyField extends IntegerField{
//Need checking if the value exists with a select_count
$num_rows=$this->related_model->select_count('where '.$this->related_model.'.'.$this->related_model->idmodel.'='.$value, $this->related_model->idmodel);
$this->related_model->set_conditions('where '.$this->related_model->name.'.'.$this->related_model->idmodel.'='.$value);
$num_rows=$this->related_model->select_count();
if($num_rows>0)
{

View file

@ -15,7 +15,7 @@ class ImageField extends PhangoField {
public $value="";
public $label="";
public $required=0;
public $form="PhangoApp\PhaModels\CoreForms::ImageForm";
public $form='PhangoApp\PhaModels\Forms\BaseForm';
public $name_file="";
public $path="";
public $url_path="";

View file

@ -22,7 +22,7 @@ class IntegerField extends PhangoField {
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::TextForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
$this->only_positive=$only_positive;
$this->min_num=$min_num;
$this->max_num=$max_num;

View file

@ -26,7 +26,7 @@ class KeyField extends PhangoField {
{
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::TextForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
}

View file

@ -17,7 +17,7 @@ class ParentField extends IntegerField{
$this->parent_model=&$parent_model;
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::SelectForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
}

View file

@ -20,7 +20,7 @@ class PasswordField extends CharField {
{
$this->min_length=5;
$this->size=$size;
$this->form='PhangoApp\PhaModels\CoreForms::PasswordForm';
$this->form='PhangoApp\PhaModels\Forms\PasswordForm';
}

View file

@ -88,7 +88,7 @@ class PhangoField {
* Form define the function for use in forms...
*/
public $form="PhangoApp\PhaModels\CoreForms::TextForm";
public $form='PhangoApp\PhaModels\Forms\BaseForm';
/**
* Array for create initial parameters for form..
@ -108,6 +108,7 @@ class PhangoField {
public $default_value='';
/**
* Method used for internal tasks related with searchs. You can overwrite this method in your PhangoField object if you need translate the value that the user want search to a real value into the database.
*/
@ -168,7 +169,7 @@ class PhangoField {
/**
* Method for create a form, you only need subclass the field if you want another form different to default
*/
/*
public function create_form()
{
@ -179,7 +180,7 @@ class PhangoField {
return $form;
}
}*/
}

View file

@ -34,7 +34,7 @@ class PrimaryField extends PhangoField {
* By default, the form used for this field is HiddenForm.
*/
public $form="PhangoApp\PhaModels\CoreForms::HiddenForm";
public $form='PhangoApp\PhaModels\Forms\BaseForm';
/**
* By default this field is protected.
@ -82,7 +82,7 @@ class PrimaryField extends PhangoField {
/**
* By default primaryfield use a hidden form
*/
/*
public function create_form()
{
@ -94,7 +94,7 @@ class PrimaryField extends PhangoField {
return $form;
}
}*/
}

View file

@ -12,7 +12,7 @@ class SerializeField extends PhangoField {
public $value="";
public $label="";
public $required=0;
public $form="TextForm";
public $form='PhangoApp\PhaModels\Forms\BaseForm';
public $quot_open='\'';
public $quot_close='\'';
public $std_error='';

View file

@ -22,7 +22,7 @@ class TextField extends PhangoField {
function __construct($multilang=0)
{
$this->form='PhangoApp\PhaModels\CoreForms::TextAreaForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
$this->multilang=$multilang;
}

View file

@ -25,7 +25,7 @@ class TextHTMLField extends PhangoField {
function __construct($multilang=0)
{
$this->form='PhangoApp\PhaModels\CoreForms::TextAreaForm';
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
$this->multilang=$multilang;
$this->set_safe_html_tags();