fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [15539] validate


From: sigurdne
Subject: [Fmsystem-commits] [15539] validate
Date: Tue, 30 Aug 2016 08:24:16 +0000 (UTC)

Revision: 15539
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15539
Author:   sigurdne
Date:     2016-08-30 08:24:15 +0000 (Tue, 30 Aug 2016)
Log Message:
-----------
validate

Modified Paths:
--------------
    trunk/rental/inc/model/class.model.inc.php

Modified: trunk/rental/inc/model/class.model.inc.php
===================================================================
--- trunk/rental/inc/model/class.model.inc.php  2016-08-30 07:16:55 UTC (rev 
15538)
+++ trunk/rental/inc/model/class.model.inc.php  2016-08-30 08:24:15 UTC (rev 
15539)
@@ -273,16 +273,20 @@
                                        continue;
                                }
 
-                               $v = trim($entity->get_field($field));
+                               $value = $entity->get_field($field);
+                               if(!is_array($value))
+                               {
+                                       $value = trim($value);
+                               }
                                $empty = false;
 
                                if (isset($params['manytomany']) && 
isset($params['manytomany']['column']))
                                {
                                        $sub_entity_count = 0;
 
-                                       if (!empty($entity->get_field($field)) 
&& is_array($entity->get_field($field)))
+                                       if (!empty($value) && is_array($value))
                                        {
-                                               foreach 
($entity->get_field($field) as $key => $sub_entity)
+                                               foreach ($value as $key => 
$sub_entity)
                                                {
                                                        $this->_validate(
                                                                
(array)$sub_entity, (array)$params['manytomany']['column'], $errors, 
sprintf('%s%s[%s]', $field_prefix, empty($field_prefix) ? $field : 
"[{$field}]", (is_string($key) ? $key : $sub_entity_count))
@@ -315,20 +319,20 @@
                                        }
                                }
                                $error_key = empty($field_prefix) ? $field : 
"{$field_prefix}[{$field}]";
-                               if ($params['required'] && (!isset($v) || ($v 
!== '0' && empty($v))) && !$alternatives_ok)
+                               if ($params['required'] && (!isset($value) || 
($value !== '0' && empty($value))) && !$alternatives_ok)
                                {
 
                                        $errors[$error_key] = lang("Field %1 is 
required", lang($error_key));
                                        $empty = true;
                                }
-                               if ($params['type'] == 'date' && 
!empty($entity->get_field($field)))
+                               if ($params['type'] == 'date' && !empty($value))
                                {
                                        /**
                                         * Already converted to integer
                                         */
-                                       //$date = 
date_parse($entity->get_field($field));
+                                       //$date = date_parse($value);
                                        //if (!$date || count($date['errors']) 
> 0)
-                                       if 
(!ctype_digit($entity->get_field($field)))
+                                       if (!ctype_digit($value))
                                        {
                                                $errors[$error_key] = 
lang("Field %1: Invalid format", lang($error_key));
                                        }
@@ -339,7 +343,7 @@
                                        try
                                        {
                                                
$params['sf_validator']->setOption('required', false);
-                                               
$params['sf_validator']->clean($entity->get_field($field));
+                                               
$params['sf_validator']->clean($value);
                                        }
                                        catch (sfValidatorError $e)
                                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]