|
@@ -273,67 +273,6 @@ EOF
|
|
);
|
|
);
|
|
break;
|
|
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)
|
|
// ... and in read-only mode (or hidden)
|
|
else
|
|
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;
|
|
return $oOutput;
|
|
}
|
|
}
|
|
|
|
|