Laurent Destailleur hace 3 años
padre
commit
e1a45df0d8
Se han modificado 2 ficheros con 7 adiciones y 4 borrados
  1. 6 3
      htdocs/core/class/html.formadmin.class.php
  2. 1 1
      test/phpunit/FormAdminTest.php

+ 6 - 3
htdocs/core/class/html.formadmin.class.php

@@ -393,9 +393,10 @@ class FormAdmin
 	 *  @param      string	$htmlname       Name of HTML select field
 	 *  @param		string	$filter			Value to filter on code
 	 *  @param		int		$showempty		Add empty value
+	 * 	@param		int		$forcecombo		Force to load all values and output a standard combobox (with no beautification)
 	 *  @return		string					Return HTML output
 	 */
-	public function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0)
+	public function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0, $forcecombo = 0)
 	{
 		// phpcs:enable
 		global $langs;
@@ -444,8 +445,10 @@ class FormAdmin
 		}
 		$out .= '</select>';
 
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
-		$out .= ajax_combobox($htmlname);
+		if (!$forcecombo) {
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+			$out .= ajax_combobox($htmlname);
+		}
 
 		return $out;
 	}

+ 1 - 1
test/phpunit/FormAdminTest.php

@@ -139,7 +139,7 @@ class FormAdminTest extends PHPUnit\Framework\TestCase
 		$db=$this->savdb;
 
 		$localobject=new FormAdmin($this->savdb);
-		$result=$localobject->select_paper_format('', 'paperformat_id', 'A4');
+		$result=$localobject->select_paper_format('', 'paperformat_id', 'A4', 0, 1);
 
 		$this->assertEquals($result, '<select class="flat" id="paperformat_id" name="paperformat_id"><option value="EUA4">Format A4 - 210x297 mm</option></select>');
 		print __METHOD__." result=".$result."\n";