Pārlūkot izejas kodu

N°991 Portal: Fixed a regression introduced in r4855 (N°743); request template selection was not working when several templates available.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4862 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 7 gadi atpakaļ
vecāks
revīzija
420ba72941

+ 66 - 61
sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php

@@ -273,67 +273,6 @@ EOF
                     );
                     break;
             }
-
-            // JS Form field widget construct
-            $aValidators = array();
-            foreach ($this->oField->GetValidators() as $oValidator)
-            {
-                $aValidators[$oValidator::GetName()] = array(
-                    'reg_exp' => $oValidator->GetRegExp(),
-                    'message' => Dict::S($oValidator->GetErrorMessage())
-                );
-            }
-
-            $sFormFieldOptions = json_encode(array(
-                'validators' => $aValidators
-            ));
-
-            switch ($sFieldClass)
-            {
-                case 'Combodo\\iTop\\Form\\Field\\PasswordField':
-                case 'Combodo\\iTop\\Form\\Field\\StringField':
-                case 'Combodo\\iTop\\Form\\Field\\UrlField':
-                case 'Combodo\\iTop\\Form\\Field\\EmailField':
-                case 'Combodo\\iTop\\Form\\Field\\SelectField':
-                case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
-                case 'Combodo\\iTop\\Form\\Field\\HiddenField':
-                case 'Combodo\\iTop\\Form\\Field\\RadioField':
-                case 'Combodo\\iTop\\Form\\Field\\CheckboxField':
-                case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
-                    $oOutput->AddJs(
-                        <<<EOF
-    					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field($sFormFieldOptions);
-EOF
-                    );
-                    break;
-                case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
-                case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
-                    $bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML);
-                    if($bRichEditor)
-                    {
-                        // Overloading $sFormFieldOptions to include the set_current_value_callback. It would have been nicer to refactor the variable for all field types, but as this is a fix for a maintenance release, we rather be safe.
-                        $sValidators = json_encode($aValidators);
-                        $oOutput->AddJs(
-                            <<<EOF
-                            $("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html({
-                            validators: $sValidators,
-                            set_current_value_callback: function(me, oEvent, oData){ $(me.element).find('textarea').val(oData); }
-                        });
-EOF
-                        );
-                        // MagnificPopup on images
-                        $oOutput->AddJs(InlineImage::FixImagesWidth());
-                    }
-                    else
-                    {
-                        $oOutput->AddJs(
-                            <<<EOF
-        					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field($sFormFieldOptions);
-EOF
-                        );
-                    }
-                    break;
-            }
 		}
 		// ... and in read-only mode (or hidden)
 		else
@@ -512,6 +451,72 @@ EOF
 			}
 		}
 
+		// Attaching JS widget only if field is hidden or NOT read only
+        if($this->oField->GetHidden() || !$this->oField->GetReadOnly())
+        {
+
+            // JS Form field widget construct
+            $aValidators = array();
+            foreach ($this->oField->GetValidators() as $oValidator)
+            {
+                $aValidators[$oValidator::GetName()] = array(
+                    'reg_exp' => $oValidator->GetRegExp(),
+                    'message' => Dict::S($oValidator->GetErrorMessage())
+                );
+            }
+
+            $sFormFieldOptions = json_encode(array(
+                'validators' => $aValidators
+            ));
+
+            switch ($sFieldClass)
+            {
+                case 'Combodo\\iTop\\Form\\Field\\PasswordField':
+                case 'Combodo\\iTop\\Form\\Field\\StringField':
+                case 'Combodo\\iTop\\Form\\Field\\UrlField':
+                case 'Combodo\\iTop\\Form\\Field\\EmailField':
+                case 'Combodo\\iTop\\Form\\Field\\SelectField':
+                case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
+                case 'Combodo\\iTop\\Form\\Field\\HiddenField':
+                case 'Combodo\\iTop\\Form\\Field\\RadioField':
+                case 'Combodo\\iTop\\Form\\Field\\CheckboxField':
+                case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
+                    $oOutput->AddJs(
+                        <<<EOF
+    					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field($sFormFieldOptions);
+EOF
+                    );
+                    break;
+                case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
+                case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
+                    $bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML);
+                    if($bRichEditor)
+                    {
+                        // Overloading $sFormFieldOptions to include the set_current_value_callback. It would have been nicer to refactor the variable for all field types, but as this is a fix for a maintenance release, we rather be safe.
+                        $sValidators = json_encode($aValidators);
+                        $oOutput->AddJs(
+                            <<<EOF
+                            $("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html({
+                            validators: $sValidators,
+                            set_current_value_callback: function(me, oEvent, oData){ $(me.element).find('textarea').val(oData); }
+                        });
+EOF
+                        );
+                        // MagnificPopup on images
+                        $oOutput->AddJs(InlineImage::FixImagesWidth());
+                    }
+                    else
+                    {
+                        $oOutput->AddJs(
+                            <<<EOF
+        					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field($sFormFieldOptions);
+EOF
+                        );
+                    }
+                    break;
+            }
+        }
+
 		return $oOutput;
 	}