From 37e3cb628567f2cfb4820eff6bf7f638f81dc69a Mon Sep 17 00:00:00 2001 From: Guillaume Lajarige Date: Wed, 16 Mar 2016 16:46:58 +0000 Subject: [PATCH] Form : Added some translations to the new form system SVN:trunk[3953] --- sources/form/field/selectfield.class.inc.php | 22 +++++++------------ .../bssimplefieldrenderer.class.inc.php | 4 +++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sources/form/field/selectfield.class.inc.php b/sources/form/field/selectfield.class.inc.php index c7b9a0a4f..6afd5106d 100644 --- a/sources/form/field/selectfield.class.inc.php +++ b/sources/form/field/selectfield.class.inc.php @@ -20,6 +20,7 @@ namespace Combodo\iTop\Form\Field; use \Closure; +use \Dict; use \Combodo\iTop\Form\Field\MultipleChoicesField; /** @@ -29,7 +30,7 @@ use \Combodo\iTop\Form\Field\MultipleChoicesField; */ class SelectField extends MultipleChoicesField { - const DEFAULT_NULL_CHOICE_LABEL = 'TOTR: - Choisir une valeur -'; + const DEFAULT_NULL_CHOICE_LABEL = 'UI:SelectOne'; const DEFAULT_STARTS_WITH_NULL_CHOICE = true; protected $bStartsWithNullChoice; @@ -55,30 +56,23 @@ class SelectField extends MultipleChoicesField { $this->bStartsWithNullChoice = $bStartsWithNullChoice; - if (!array_key_exists(null, $this->aChoices)) - { - $this->aChoices = array(null => static::DEFAULT_NULL_CHOICE_LABEL) + $this->aChoices; - } - return $this; } /** - * Sets the choices for the fields - * Overloads the methods for the super class in order to put a dummy choice first if necessary. + * Returns the field choices with null choice first * - * @param array $aChoices - * @return \Combodo\iTop\Form\Field\SelectField + * @return array */ - public function SetChoices($aChoices) + public function GetChoices() { + $aChoices = parent::GetChoices(); if ($this->bStartsWithNullChoice && !array_key_exists(null, $aChoices)) { - $aChoices = array(null => static::DEFAULT_NULL_CHOICE_LABEL) + $aChoices; + $aChoices = array(null => Dict::S(static::DEFAULT_NULL_CHOICE_LABEL)) + $aChoices; } - parent::SetChoices($aChoices); - return $this; + return $aChoices; } } diff --git a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php index 4bf0d8674..5ff7c77eb 100644 --- a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php +++ b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php @@ -103,7 +103,7 @@ EOF { // Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int) $sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : ''; - $oOutput->AddHtml(''); + $oOutput->AddHtml(''); } $oOutput->AddHtml(''); $oOutput->AddHtml(''); @@ -267,6 +267,8 @@ EOF $("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html($sFormFieldOptions); EOF ); + // MagnificPopup on images + $oOutput->AddJs(InlineImage::FixImagesWidth()); break; }