diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php
index 00222bcce61..7b625066390 100644
--- a/dev/skeletons/skeleton_page.php
+++ b/dev/skeletons/skeleton_page.php
@@ -70,17 +70,38 @@ if ($user->societe_id > 0)
if ($action == 'add')
{
+ $error=0;
+
$object=new Skeleton_Class($db);
- $object->prop1=$_POST["field1"];
- $object->prop2=$_POST["field2"];
- $result=$object->create($user);
- if ($result > 0)
+ /* object_prop_getpost_prop */
+ $object->prop1=GETPOST("field1");
+ $object->prop2=GETPOST("field2");
+
+ if (empty($object->ref))
{
- // Creation OK
+ $error++;
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors');
}
+
+ if (! $error)
{
- // Creation KO
- $mesg=$object->error;
+ $result=$object->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ header("Location: ".dol_buildpath('/mymodule/list.php',1));
+ exit;
+ }
+ {
+ // Creation KO
+ if (! empty($object->errors)) setEventMessage($object->errors, 'errors');
+ else setEventMessage($object->error, 'errors');
+ $action='create';
+ }
+ }
+ else
+ {
+ $action='create';
}
}
@@ -145,21 +166,18 @@ if ($action == 'list')
{
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
+ while ($i < $num)
{
- while ($i < $num)
+ $obj = $db->fetch_object($resql);
+ if ($obj)
{
- $obj = $db->fetch_object($resql);
- if ($obj)
- {
- // You can use here results
- print '
| ';
- print $obj->field1;
- print $obj->field2;
- print ' |
';
- }
- $i++;
+ // You can use here results
+ print '| ';
+ print $obj->field1;
+ print $obj->field2;
+ print ' |
';
}
+ $i++;
}
}
else
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index c57b79ea7fa..9b57e57bc0b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -481,7 +481,7 @@ class Form
$countryArray=array();
$label=array();
- $sql = "SELECT rowid, code as code_iso, libelle as label";
+ $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE active = 1";
//$sql.= " ORDER BY code ASC";
@@ -502,6 +502,7 @@ class Form
$obj = $this->db->fetch_object($resql);
$countryArray[$i]['rowid'] = $obj->rowid;
$countryArray[$i]['code_iso'] = $obj->code_iso;
+ $countryArray[$i]['code_iso3'] = $obj->code_iso3;
$countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$label[$i] = dol_string_unaccent($countryArray[$i]['label']);
$i++;
@@ -512,7 +513,7 @@ class Form
foreach ($countryArray as $row)
{
//print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'
';
- if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) )
+ if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) )
{
$foundselected=true;
$out.= '