Little fixes in forms

This commit is contained in:
Antonio de la Rosa 2016-11-19 05:26:23 +01:00
parent 86125bf06d
commit b5b4740b7c
6 changed files with 25 additions and 12 deletions

View file

@ -70,22 +70,25 @@ class DateField extends PhangoField {
} }
else if(strpos($value, '-')!==false) else if(strpos($value, '-')!==false)
{ {
$arr_time=explode('-',trim($value)); $arr_time=explode('-',trim($value));
settype($arr_time[0], 'integer'); settype($arr_time[0], 'integer');
settype($arr_time[1], 'integer'); settype($arr_time[1], 'integer');
settype($arr_time[2], 'integer'); settype($arr_time[2], 'integer');
$final_value=mktime (0, 0, 0, $arr_time[1], $arr_time[0], $arr_time[2] ); //$final_value=PhaTime\DateTime::obtain_timestamp(mktime (0, 0, 0, $arr_time[1], $arr_time[0], $arr_time[2] ));
$value=date(PhaTime\DateTime::$sql_format_time, mktime(0, 0, 0, $arr_time[1], $arr_time[2], $arr_time[0]));
/*
if($final_value===false) if($final_value===false)
{ {
$this->error=1; $this->error=1;
$final_value=PhaTime\DateTime::local_to_gmt(date(PhaTime\DateTime::$sql_format_time)); $final_value=PhaTime\DateTime::local_to_gmt(date(PhaTime\DateTime::$sql_format_time));
} }*/
} }
if(PhaTime\DateTime::obtain_timestamp($value)) if(PhaTime\DateTime::obtain_timestamp($value))
{ {

View file

@ -42,7 +42,7 @@ class NormalizeField extends TextField {
static public function check_text($value, $separator='-') static public function check_text($value, $separator='-')
{ {
$str_normalize=PhangoApp\PhaUtils\Utils::slugify(strip_tags($value)); $str_normalize=\PhangoApp\PhaUtils\Utils::slugify(strip_tags($value));
$arr_normalize=explode($separator, $str_normalize); $arr_normalize=explode($separator, $str_normalize);

View file

@ -2,6 +2,8 @@
namespace PhangoApp\PhaModels\CoreFields; namespace PhangoApp\PhaModels\CoreFields;
use PhangoApp\PhaI18n\I18n;
class PercentField extends IntegerField{ class PercentField extends IntegerField{
@ -16,7 +18,7 @@ class PercentField extends IntegerField{
if($value>100 || $value<0) if($value>100 || $value<0)
{ {
$this->std_error=i18n_lang('common', 'the_value_can_not_be_greater_than_100', 'The value cannot be greater than 100'); $this->std_error=I18n::lang('common', 'the_value_can_not_be_greater_than_100', 'The value cannot be greater or minor than 100');
$this->error=1; $this->error=1;
@ -28,8 +30,15 @@ class PercentField extends IntegerField{
} }
public function show_formatted($value)
{
return $value.' %';
}
} }
?> ?>

View file

@ -36,12 +36,13 @@ class BaseForm {
$this->field=new CharField(); $this->field=new CharField();
$this->comment_form=''; $this->comment_form='';
$this->txt_error = I18n::lang('common', 'error_in_field', 'Error in field'); $this->txt_error = I18n::lang('common', 'error_in_field', 'Error in field');
$this->extra_param='';
} }
public function form() public function form()
{ {
return '<input type="'.$this->type.'" id="'.$this->name.'_field_form" class="'.$this->css.'" name="'.$this->name.'" value="'.$this->setform($this->default_value).'"> '.$this->comment_form; return '<input type="'.$this->type.'" id="'.$this->name.'_field_form" class="'.$this->css.'" name="'.$this->name.'" value="'.$this->setform($this->default_value).'" '.$this->extra_param.'> '.$this->comment_form;
} }

View file

@ -25,7 +25,7 @@ class FileForm extends BaseForm{
public function form() public function form()
{ {
return '<input type="'.$this->type.'" class="'.$this->css.'" name="'.$this->name.'_file" value=""> <a href="'.$this->file_url.'/'.$this->default_value.'">'.Utils::form_text($this->default_value).'</a><input type="hidden" 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.'_file" value=""> <a href="'.$this->file_url.'/'.$this->default_value.'">'.Utils::form_text($this->default_value).'</a><input type="hidden" name="'.$this->name.'" value="'.$this->setform($this->default_value).'" />';
} }
@ -33,4 +33,4 @@ class FileForm extends BaseForm{
} }
?> ?>

View file

@ -14,10 +14,10 @@ class TextAreaForm extends BaseForm {
{ {
?> ?>
<p><textarea class="tinymce_editor" name="<?php echo $this->name; ?>"><?php echo $this->setform($this->default_value); ?></textarea></p> <textarea id="<?php echo $this->name; ?>_field_form" name="<?php echo $this->name; ?>" class="<?php echo $this->css; ?>"><?php echo $this->setform($this->default_value); ?></textarea>
<?php <?php
} }
} }
?> ?>