From 243767bc12436e1d0210d74968a1967feaa519f9 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Wed, 16 Dec 2015 15:28:10 +0100 Subject: [PATCH] Little fixes --- src/CoreFields/CharField.php | 9 +++++++++ src/CoreFields/PhangoField.php | 16 ++++++++++++++++ src/Databases/MySQLClass.php | 2 +- src/ModelForm.php | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/CoreFields/CharField.php b/src/CoreFields/CharField.php index 01ca582..aeefd3b 100644 --- a/src/CoreFields/CharField.php +++ b/src/CoreFields/CharField.php @@ -48,6 +48,7 @@ class CharField extends PhangoField { /** * This function is for check if the value for field is valid + * If required and empty check how false */ public function check($value) @@ -55,6 +56,14 @@ class CharField extends PhangoField { //Delete Javascript tags and simple quotes. $this->value=Utils::form_text($value); + + if($value=='') + { + + $this->error=1; + + } + return Utils::form_text($value); } diff --git a/src/CoreFields/PhangoField.php b/src/CoreFields/PhangoField.php index 2d645d1..d226a07 100644 --- a/src/CoreFields/PhangoField.php +++ b/src/CoreFields/PhangoField.php @@ -120,6 +120,11 @@ class PhangoField { public $update=0; + /** + * A property for set if error + */ + + public $error=0; /** * 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. @@ -178,6 +183,17 @@ class PhangoField { } + /** + * Basic check for sql things + */ + + public function check($value) + { + + return str_replace('"', '"', $value); + + } + /** * Method for create a form, you only need subclass the field if you want another form different to default */ diff --git a/src/Databases/MySQLClass.php b/src/Databases/MySQLClass.php index 9a5a983..82b91bb 100644 --- a/src/Databases/MySQLClass.php +++ b/src/Databases/MySQLClass.php @@ -2,7 +2,7 @@ namespace PhangoApp\PhaModels; -if(!function_exists('mysql_query')) +if(!function_exists('mysqli_query')) { throw new \Exception('Error: Mysql database don\'t supported by php'); diff --git a/src/ModelForm.php b/src/ModelForm.php index ff634f5..118f711 100644 --- a/src/ModelForm.php +++ b/src/ModelForm.php @@ -320,6 +320,8 @@ class ModelForm { $post[$key_form]=$form->field->check($post[$key_form]); + //If isset how false the error field..., then error. + if($post[$key_form]=='' && $form->required==1) {