diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php
index 4fe9b905eda..565866e2d90 100644
--- a/htdocs/core/ajax/selectsearchbox.php
+++ b/htdocs/core/ajax/selectsearchbox.php
@@ -44,14 +44,14 @@ if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE
{
$langs->load("companies");
//$searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'soc', 'sall', 'T', 'searchleftt', img_object('','company'));
- $arrayresult['searchintothirdparty']=img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue);
+ $arrayresult['searchintothirdparty']=array('text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php?sall='.urlencode($search_boxvalue));
}
if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire)
{
$langs->load("companies");
//$searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', $langs->trans("Contacts"), 'contact', 'sall', 'A', 'searchleftc', img_object('','contact'));
- $arrayresult['searchintocontact']=img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue);
+ $arrayresult['searchintocontact']=array('text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php?sall='.urlencode($search_boxvalue));
}
if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire))
@@ -59,7 +59,7 @@ if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! em
{
$langs->load("products");
//$searchform.=printSearchForm(DOL_URL_ROOT.'/product/list.php', DOL_URL_ROOT.'/product/list.php', $langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall', 'P', 'searchleftp', img_object('','product'));
- $arrayresult['searchintoproduct']=img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue);
+ $arrayresult['searchintoproduct']=array('text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php?sall='.urlencode($search_boxvalue));
}
/*if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) && ! empty($conf->fournisseur->enabled)
@@ -73,14 +73,14 @@ if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_
{
$langs->load("members");
//$searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/list.php', DOL_URL_ROOT.'/adherents/list.php', $langs->trans("Members"), 'member', 'sall', 'M', 'searchleftm', img_object('','user'));
- $arrayresult['searchintomember']=img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue);
+ $arrayresult['searchintomember']=array('text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php?sall='.urlencode($search_boxvalue));
}
if (! empty($conf->projet->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_PROJECT) && $user->rights->projet->lire)
{
$langs->load("projects");
//$searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub'));
- $arrayresult['searchintoprojects']=img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue);
+ $arrayresult['searchintoprojects']=array('text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php?search_all='.urlencode($search_boxvalue));
}
// Execute hook printSearchForm
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 5f714a85bcd..1e11f103a39 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -4504,16 +4504,17 @@ class Form
* Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice.
*
* @param string $htmlname Name of html select area
- * @param string $url Url
+ * @param string $url Url. Must return a json_encode of array(key=>array('text'=>'A text', 'url'=>'An url'), ...)
* @param string $id Preselected key
* @param string $moreparam Add more parameters onto the select tag
* @param string $moreparamtourl Add more parameters onto the Ajax called URL
* @param int $disabled Html select box is disabled
* @param int $minimumInputLength Minimum Input Length
* @param string $morecss Add more class to css styles
+ * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected.
* @return string HTML select string.
*/
- static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='')
+ static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0)
{
$out = '';
@@ -4521,7 +4522,10 @@ class Form
$out.='
';
diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php
index 5e7b2f2434f..a189ee836b1 100644
--- a/htdocs/public/test/test_forms.php
+++ b/htdocs/public/test/test_forms.php
@@ -64,11 +64,11 @@ print $form->selectarray('selectarray',$array);
print '
'."\n";
-print "Test 4d: a select with ajax refresh
\n";
+print "Test 4d: a select with ajax refresh and with onchange call of url
\n";
//$array=array(0=>'',1=>'Search into xxx',2=>'Search into yyy',3=>'Search into zzz');
$array=array();
$selected=-1;
-print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'style="min-width: 250px;"', '', 0, 1, '');
+print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'style="min-width: 250px;"', '', 0, 1, '', 1);
print '
'."\n";