diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
old mode 100644
new mode 100755
index 3050590..e682711
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -41,7 +41,7 @@ class Adherent extends CommonObject
     public $element='member';
     public $table_element='adherent';
     protected $ismultientitymanaged = 1;  // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
-
+	protected $elementType='member';
     var $id;
     var $ref;
     var $civilite_id;
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
old mode 100644
new mode 100755
index 0a9dae0..d9ac97f
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -36,7 +36,8 @@ class Contact extends CommonObject
 {
 	public $element='contact';
 	public $table_element='socpeople';
-
+	protected $elementType='contact';
+	
 	var $id;
 	var $civilite_id;  // In fact we stor civility_code
     var $lastname;
diff --git a/htdocs/core/admin_extrafields.inc.php b/htdocs/core/admin_extrafields.inc.php
old mode 100644
new mode 100755
index 00d4e4c..0d251a6
--- a/htdocs/core/admin_extrafields.inc.php
+++ b/htdocs/core/admin_extrafields.inc.php
@@ -35,7 +35,15 @@ if ($action == 'add')
             $action = 'create';
         }
 
-	    if (! $error)
+	    if (GETPOST('type')=='int' && GETPOST('size') > 11)
+        {
+            $error++;
+            $langs->load("errors");
+            $mesg=$langs->trans("ErrorSizeTooLongForIntType");
+            $action = 'create';
+        }
+        
+        if (! $error)
 	    {
     		// Type et taille non encore pris en compte => varchar(255)
     		if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
@@ -76,7 +84,14 @@ if ($action == 'update')
             $mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
             $action = 'edit';
         }
-
+        if (GETPOST('type')=='int' && GETPOST('size') > 11)
+        {
+        	$error++;
+        	$langs->load("errors");
+        	$mesg=$langs->trans("ErrorSizeTooLongForIntType");
+        	$action = 'edit';
+        }
+        
 	    if (! $error)
 	    {
             if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
old mode 100644
new mode 100755
index 064386e..ba3e26a
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -35,7 +35,8 @@ abstract class CommonObject
     public $error;
     public $errors;
     public $canvas;                // Contains canvas name if it is
-
+	
+    protected $elementType='member';
 
     // No constructor as it is an abstract class
 
@@ -1682,6 +1683,33 @@ abstract class CommonObject
     {
         if (count($this->array_options) > 0)
         {
+            require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
+            $extrafields = new ExtraFields($this->db);
+            $optionsArray = $extrafields->fetch_name_optionals_label($this->elementType);
+
+            dol_syslog(get_class($this)."::insertExtraFields -------------------------------");
+            dol_syslog('elementType=' . $this->elementType);
+            foreach($this->array_options as $key => $value)
+            {
+            	$attributeKey = substr($key,8);   // Remove 'options_' prefix
+            	$attributeType = $extrafields->attribute_type[$attributeKey];
+            	$attributeSize = $extrafields->attribute_size[$attributeKey];
+            	$attributeLabel = $extrafields->attribute_label[$attributeKey];
+            	switch ($attributeType) 
+            	{
+            		case 'int':
+            			if (!is_numeric($value) && $value!='')
+            			{
+            				$error++; $this->errors[]="Field ". $attributeLabel . " is not a numeric value";
+            				return -1;
+            			}
+            			elseif ($value=='') 
+            				$this->array_options[$key] = null;
+            			break;
+            	}
+            }
+            dol_syslog(get_class($this)."::insertExtraFields -------------------------------");
+        	 
             $this->db->begin();
 
             $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 86ebf20..17beef7 100755
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -419,28 +419,33 @@ class ExtraFields
         {
             $showsize=19;
         }
-        elseif ($type == 'int')
-        {
-            $showsize=10;
-        }
         else
         {
             $showsize=round($size);
             if ($showsize > 48) $showsize=48;
         }
-
-	    if ($type == 'varchar')
-        {
-        	$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
-        }
-        else if ($type == 'text')
-        {
-        	require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
-        	$doleditor=new DolEditor('options_'.$key,$value,'',200,'dolibarr_notes','In',false,false,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100);
-        	$out=$doleditor->Create(1);
-        }
-	    else if ($type == 'date') $out.=' (YYYY-MM-DD)';
-        else if ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
+        
+        $out_comment = '';
+		switch ($type)
+		{
+			case 'date':
+				$out_comment=' (YYYY-MM-DD)';
+				
+			case 'datetime':
+				$out_comment=' (YYYY-MM-DD HH:MM:SS)';
+			
+			case 'int':
+			case 'varchar':
+				$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
+				$out.=$out_comment;
+				break;
+				
+			case 'text':
+	        	require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
+	        	$doleditor=new DolEditor('options_'.$key,$value,'',200,'dolibarr_notes','In',false,false,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100);
+	        	$out=$doleditor->Create(1);
+				break;
+		}
 	    return $out;
 	}
 
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
old mode 100644
new mode 100755
index 9c8d61f..ba0398e
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -40,6 +40,7 @@ class Product extends CommonObject
 	protected $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur_price');
 	protected $isnolinkedbythird = 1;     // No field fk_soc
 	protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+	protected $elementType='product';
 
 	//! Identifiant unique
 	var $id ;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
old mode 100644
new mode 100755
index abcc593..1641cbd
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -41,6 +41,7 @@ class Societe extends CommonObject
 	public $fk_element='fk_soc';
     protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur");
     protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+    protected $elementType='company';
 
     var $id;
     var $name;
