Explorar el Código

Forms: drop-down box default value label could be changed (or this entry could be entirely removed)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3367 a333f486-631f-4898-b8df-5754b55c2be0
romainq hace 10 años
padre
commit
de997f7fcc
Se han modificado 1 ficheros con 14 adiciones y 2 borrados
  1. 14 2
      application/forms.class.inc.php

+ 14 - 2
application/forms.class.inc.php

@@ -957,6 +957,7 @@ class DesignerComboField extends DesignerFormField
 	protected $aAllowedValues;
 	protected $aAllowedValues;
 	protected $bMultipleSelection;
 	protected $bMultipleSelection;
 	protected $bOtherChoices;
 	protected $bOtherChoices;
+	protected $sNullLabel;
 	
 	
 	public function __construct($sCode, $sLabel = '', $defaultValue = '')
 	public function __construct($sCode, $sLabel = '', $defaultValue = '')
 	{
 	{
@@ -964,6 +965,7 @@ class DesignerComboField extends DesignerFormField
 		$this->aAllowedValues = array();
 		$this->aAllowedValues = array();
 		$this->bMultipleSelection = false;
 		$this->bMultipleSelection = false;
 		$this->bOtherChoices = false;
 		$this->bOtherChoices = false;
+		$this->sNullLabel = Dict::S('UI:SelectOne');
 
 
 		$this->bAutoApply = true;
 		$this->bAutoApply = true;
 	}
 	}
@@ -982,7 +984,14 @@ class DesignerComboField extends DesignerFormField
 	{
 	{
 		$this->bOtherChoices = $bOtherChoices;
 		$this->bOtherChoices = $bOtherChoices;
 	}
 	}
-	
+
+	/**
+	 * An empty label will disable the default empty value
+	 */	 	
+	public function SetNullLabel($sLabel)
+	{
+		$this->sNullLabel = $sLabel;
+	}
 	
 	
 	public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
 	public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
 	{
 	{
@@ -1030,7 +1039,10 @@ class DesignerComboField extends DesignerFormField
 			else
 			else
 			{
 			{
 				$sHtml = "<select $sCSSClasses id=\"$sId\" name=\"$sName\">";
 				$sHtml = "<select $sCSSClasses id=\"$sId\" name=\"$sName\">";
-				$sHtml .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>";
+				if ($this->sNullLabel != '')
+				{
+					$sHtml .= "<option value=\"\">".$this->sNullLabel."</option>";
+				}
 			}
 			}
 			foreach($this->aAllowedValues as $sKey => $sDisplayValue)
 			foreach($this->aAllowedValues as $sKey => $sDisplayValue)
 			{
 			{