mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 00:02:17 +02:00
N°1318 - multiple choice in a template - first step
This commit is contained in:
@@ -28,5 +28,16 @@ class MultipleSelectField extends SelectField
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const DEFAULT_MULTIPLE_VALUES_ENABLED = true;
|
||||
const DEFAULT_STARTS_WITH_NULL_CHOICE = false;
|
||||
|
||||
function SetCurrentValue($currentValue)
|
||||
{
|
||||
if ($currentValue != null) {
|
||||
$this->currentValue = $currentValue;
|
||||
} else {
|
||||
$this->currentValue = "";
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
29
sources/Form/Field/MultipleSelectObjectField.php
Normal file
29
sources/Form/Field/MultipleSelectObjectField.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2023 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Form\Field;
|
||||
|
||||
|
||||
/**
|
||||
* Description of MultipleSelectObjectField
|
||||
*
|
||||
* @author Acc
|
||||
* @since 3.1.0
|
||||
*/
|
||||
class MultipleSelectObjectField extends SelectObjectField
|
||||
{
|
||||
function SetCurrentValue($currentValue)
|
||||
{
|
||||
if ($currentValue != null) {
|
||||
$this->currentValue = $currentValue;
|
||||
} else {
|
||||
$this->currentValue = "";
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,20 @@ namespace Combodo\iTop\Form\Field;
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
*/
|
||||
class TagSetField extends Field
|
||||
class TagSetField extends SelectField
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const DEFAULT_MULTIPLE_VALUES_ENABLED = true;
|
||||
const DEFAULT_STARTS_WITH_NULL_CHOICE = false;
|
||||
|
||||
function SetCurrentValue($currentValue)
|
||||
{
|
||||
if ($currentValue != null) {
|
||||
$this->currentValue = $currentValue;
|
||||
} else {
|
||||
$this->currentValue = "";
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
29
sources/Form/Field/TagSetObjectField.php
Normal file
29
sources/Form/Field/TagSetObjectField.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2023 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
// iTop is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// iTop is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
namespace Combodo\iTop\Form\Field;
|
||||
|
||||
/**
|
||||
* Description of TagSetField
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
*/
|
||||
class TagSetObjectField extends MultipleSelectObjectField
|
||||
{
|
||||
}
|
||||
@@ -10,11 +10,14 @@ use Combodo\iTop\Form\Field\DateTimeField;
|
||||
use Combodo\iTop\Form\Field\DurationField;
|
||||
use Combodo\iTop\Form\Field\HiddenField;
|
||||
use Combodo\iTop\Form\Field\LabelField;
|
||||
use Combodo\iTop\Form\Field\MultipleSelectField;
|
||||
use Combodo\iTop\Form\Field\MultipleSelectObjectField;
|
||||
use Combodo\iTop\Form\Field\RadioField;
|
||||
use Combodo\iTop\Form\Field\SelectField;
|
||||
use Combodo\iTop\Form\Field\SelectObjectField;
|
||||
use Combodo\iTop\Form\Field\StringField;
|
||||
use Combodo\iTop\Form\Field\SubFormField;
|
||||
use Combodo\iTop\Form\Field\TagSetField;
|
||||
use Combodo\iTop\Form\Field\TextAreaField;
|
||||
use Combodo\iTop\Renderer\Console\FieldRenderer\ConsoleSelectObjectFieldRenderer;
|
||||
use Combodo\iTop\Renderer\Console\FieldRenderer\ConsoleSimpleFieldRenderer;
|
||||
@@ -78,15 +81,35 @@ class ConsoleFieldRendererMappings implements iFieldRendererMappingsExtension
|
||||
'field_renderer' => ConsoleSelectObjectFieldRenderer::class,
|
||||
],
|
||||
[
|
||||
'field' => SubFormField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field' => SubFormField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field_renderer' => ConsoleSubFormFieldRenderer::class,
|
||||
],
|
||||
[
|
||||
'field' => DateTimeField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field' => DateTimeField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field_renderer' => ConsoleSimpleFieldRenderer::class,
|
||||
],
|
||||
[
|
||||
'field' => MultipleSelectField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field_renderer' => ConsoleSimpleFieldRenderer::class,
|
||||
],
|
||||
[
|
||||
'field' => MultipleSelectObjectField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field_renderer' => ConsoleSelectObjectFieldRenderer::class,
|
||||
],
|
||||
[
|
||||
'field' => TagSetField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field_renderer' => ConsoleSimpleFieldRenderer::class,
|
||||
],
|
||||
[
|
||||
'field' => TagSetObjectField::class,
|
||||
'form_renderer' => ConsoleFormRenderer::class,
|
||||
'field_renderer' => ConsoleSelectObjectFieldRenderer::class,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -51,29 +51,27 @@ class ConsoleSelectObjectFieldRenderer extends FieldRenderer
|
||||
$oBlock = FieldUIBlockFactory::MakeStandard($this->oField->GetLabel());
|
||||
$oBlock->AddDataAttribute("input-id", $this->oField->GetGlobalId());
|
||||
|
||||
$sFieldClass = get_class($this->oField);
|
||||
\IssueLog::Error($this->oField->GetLabel().':render select multi:'.$sFieldClass);
|
||||
$sEditType = 'none';
|
||||
if ($this->oField->GetReadOnly())
|
||||
{
|
||||
$oBlock->AddDataAttribute("input-type","Combodo\\iTop\\Form\\Field\\SelectObjectField\readonly");
|
||||
if ($this->oField->GetReadOnly()) {
|
||||
$oBlock->AddDataAttribute("input-type", "Combodo\\iTop\\Form\\Field\\SelectObjectField\readonly");
|
||||
$oSearch = $this->oField->GetSearch()->DeepClone();
|
||||
$oSearch->AddCondition('id', $this->oField->GetCurrentValue());
|
||||
$oSet = new DBObjectSet($oSearch);
|
||||
$oObject = $oSet->Fetch();
|
||||
if ($oObject)
|
||||
{
|
||||
if ($oObject) {
|
||||
$sCurrentLabel = $oObject->Get('friendlyname');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$sCurrentLabel = '';
|
||||
}
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard();
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", $this->oField->GetCurrentValue(), $this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(new Html($sCurrentLabel));
|
||||
$oBlock->SetValue($oValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
|
||||
|
||||
$oSearch = $this->oField->GetSearch()->DeepClone();
|
||||
$oSearch->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
|
||||
|
||||
@@ -86,110 +84,267 @@ class ConsoleSelectObjectFieldRenderer extends FieldRenderer
|
||||
|
||||
$iMaxComboLength = $this->oField->GetMaximumComboLength();
|
||||
$iCount = $oAllowedValues->Count();
|
||||
if ($iCount > $iMaxComboLength)
|
||||
{
|
||||
// Auto-complete
|
||||
//
|
||||
$oBlock->AddDataAttribute("input-type","Combodo\\iTop\\Form\\Field\\SelectObjectField\\Autocomplete");
|
||||
$sEditType = 'autocomplete';
|
||||
$aExtKeyParams = array();
|
||||
$aExtKeyParams['iFieldSize'] = 10;
|
||||
$aExtKeyParams['iMinChars'] = $this->oField->GetMinAutoCompleteChars();
|
||||
$sFieldName = $this->oField->GetGlobalId();
|
||||
$sFieldId = $sFieldName;
|
||||
$sFormPrefix = '';
|
||||
$oWidget = new UIExtKeyWidget($sTargetClass, $sFieldId, '', true);
|
||||
$aArgs = array();
|
||||
$sTitle = $this->oField->GetLabel();
|
||||
|
||||
$oPage = new CaptureWebPage();
|
||||
$sHTMLValue = $oWidget->DisplaySelect($oPage, $iMaxComboLength, false /* $bAllowTargetCreation */, $sTitle, $oSet, $this->oField->GetCurrentValue(), $this->oField->GetMandatory(), $sFieldName, $sFormPrefix, $aArgs);
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard();
|
||||
$oValue->AddSubBlock(new Html($sHTMLValue));
|
||||
$oValue->AddSubBlock(new Html($oPage->GetHtml()));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
switch ($sFieldClass) {
|
||||
case 'Combodo\\iTop\\Form\\Field\\MultipleSelectObjectField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content"]);
|
||||
$bVertical = true;
|
||||
$idx = 0;
|
||||
$aValues = $this->oField->GetCurrentValue();
|
||||
$sId = $this->oField->GetGlobalId();
|
||||
|
||||
$oOutput->AddJs($oPage->GetJS());
|
||||
$oOutput->AddJs($oPage->GetReadyJS());
|
||||
foreach ($oPage->GetCSS() as $sCss)
|
||||
{
|
||||
$oOutput->AddCss($sCss);
|
||||
}
|
||||
foreach ($oPage->GetJSFiles() as $sFile)
|
||||
{
|
||||
$oOutput->AddJsFile($sFile);
|
||||
}
|
||||
foreach ($oPage->GetCSSFiles() as $sFile)
|
||||
{
|
||||
$oOutput->AddCssFile($sFile);
|
||||
}
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("#{$this->oField->GetGlobalId()}").off("change").on("change", function(){
|
||||
var me = this;
|
||||
// N°4792 - load only the required fields
|
||||
$aFieldsToLoad = [];
|
||||
|
||||
$(this).closest(".field_set").trigger("field_change", {
|
||||
id: $(me).attr("id"),
|
||||
name: $(me).closest(".form_field").attr("data-field-id"),
|
||||
value: $(me).val()
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
});
|
||||
$aComplementAttributeSpec = MetaModel::GetNameSpec($oAllowedValues->GetClass(), FriendlyNameType::COMPLEMENTARY);
|
||||
$sFormatAdditionalField = $aComplementAttributeSpec[0];
|
||||
$aAdditionalField = $aComplementAttributeSpec[1];
|
||||
$bAddingValue = false;
|
||||
|
||||
if (count($aAdditionalField) > 0) {
|
||||
$sClassAllowed = $oAllowedValues->GetClass();
|
||||
$bAddingValue = true;
|
||||
$aFieldsToLoad[$sClassAllowed] = $aAdditionalField;
|
||||
}
|
||||
$sObjectImageAttCode = MetaModel::GetImageAttributeCode($sClassAllowed);
|
||||
if (!empty($sObjectImageAttCode)) {
|
||||
$aFieldsToLoad[$sClassAllowed][] = $sObjectImageAttCode;
|
||||
}
|
||||
$aFieldsToLoad[$sClassAllowed][] = 'friendlyname';
|
||||
$oAllowedValues->OptimizeColumnLoad($aFieldsToLoad);
|
||||
$bInitValue = false;
|
||||
while ($oObj = $oAllowedValues->Fetch()) {
|
||||
/*$aOption = [];
|
||||
$aOption['value'] = $oObj->GetKey();
|
||||
$aOption['label'] = $oObj->GetName();
|
||||
$aOption['search_label'] = utils::HtmlEntityDecode($oObj->GetName());
|
||||
|
||||
if ($oObj->IsObsolete()) {
|
||||
$aOption['obsolescence_flag'] = "1";
|
||||
}
|
||||
if ($bAddingValue) {
|
||||
$aArguments = [];
|
||||
foreach ($aAdditionalField as $sAdditionalField) {
|
||||
array_push($aArguments, $oObj->Get($sAdditionalField));
|
||||
}
|
||||
$aOption['additional_field'] = utils::HtmlEntities(vsprintf($sFormatAdditionalField, $aArguments));
|
||||
}
|
||||
if (!empty($sObjectImageAttCode)) {
|
||||
// Try to retrieve image for contact
|
||||
// @var \ormDocument $oImage
|
||||
$oImage = $oObj->Get($sObjectImageAttCode);
|
||||
if (!$oImage->IsEmpty()) {
|
||||
$aOption['picture_url'] = $oImage->GetDisplayURL($sClassAllowed, $oObj->GetKey(), $sObjectImageAttCode);
|
||||
$aOption['initials'] = '';
|
||||
} else {
|
||||
$aOption['initials'] = utils::FormatInitialsForMedallion(utils::ToAcronym($oObj->Get('friendlyname')));
|
||||
}
|
||||
}*/
|
||||
$sLabel = $oObj->GetName();
|
||||
$oCheckBox = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "checkbox_".$sId, $oObj->GetKey(), "{$sId}", "checkbox");
|
||||
if (in_array($oObj->GetKey(), $aValues, true)) {
|
||||
$oCheckBox->GetInput()->SetIsChecked(true);
|
||||
}
|
||||
$oCheckBox->SetBeforeInput(false);
|
||||
$oCheckBox->GetInput()->AddCSSClass('ibo-input-checkbox');
|
||||
$oValue->AddSubBlock($oCheckBox);
|
||||
if ($bVertical) {
|
||||
$oValue->AddSubBlock(new Html("<br>"));
|
||||
}
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("#{$sId}_{$idx}").off("change").on("change", function(){
|
||||
$('#{$sId}').val(this.value).trigger('change');
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
elseif($this->oField->GetControlType() == SelectObjectField::CONTROL_RADIO_VERTICAL)
|
||||
{
|
||||
$oBlock->AddDataAttribute("input-type","Combodo\\iTop\\Form\\Field\\SelectObjectField\\Radio");
|
||||
// Radio buttons (vertical)
|
||||
//
|
||||
$sEditType = 'radio';
|
||||
$bVertical = true;
|
||||
$idx = 0;
|
||||
$bMandatory = $this->oField->GetMandatory();
|
||||
$value = $this->oField->GetCurrentValue();
|
||||
$sId = $this->oField->GetGlobalId();
|
||||
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard();
|
||||
|
||||
while ($oObject = $oSet->Fetch())
|
||||
{
|
||||
$iObject = $oObject->GetKey();
|
||||
$sLabel = $oObject->Get('friendlyname');
|
||||
if (($iCount == 1) && $bMandatory)
|
||||
{
|
||||
// When there is only once choice, select it by default
|
||||
$sSelected = 'checked';
|
||||
$value = $iObject;
|
||||
);
|
||||
$idx++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sSelected = ($value == $iObject) ? 'checked' : '';
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", json_encode($aValues), $sId));
|
||||
$oValue->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
break;
|
||||
case 'Combodo\\iTop\\Form\\Field\\TagSetObjectField':
|
||||
/** @var \ormSet $value code qui vient des tagset
|
||||
* $sJson = $oAttDef->GetJsonForWidget($value, $aArgs);
|
||||
* $sEscapedJson = utils::EscapeHtml($sJson);
|
||||
* $sSetInputName = "attr_{$sFormPrefix}{$sAttCode}";
|
||||
*
|
||||
* // handle form validation
|
||||
* $aEventsList[] = 'change';
|
||||
* $aEventsList[] = 'validate';
|
||||
* $sNullValue = '';
|
||||
* $sFieldToValidateId = $sFieldToValidateId.AttributeSet::EDITABLE_INPUT_ID_SUFFIX;
|
||||
*
|
||||
* // generate form HTML output
|
||||
* $sValidationSpan = "<span class=\"form_validation ibo-field-validation\" id=\"v_{$sFieldToValidateId}\"></span>";
|
||||
* $sHTMLValue = '<div class="field_input_zone field_input_set ibo-input-wrapper ibo-input-tagset-wrapper" data-validation="untouched"><input id="'.$iId.'" name="'.$sSetInputName.'" type="hidden" value="'.$sEscapedJson.'"></div>'.$sValidationSpan.$sReloadSpan;
|
||||
* $sScript = "$('#$iId').set_widget({inputWidgetIdSuffix: '".AttributeSet::EDITABLE_INPUT_ID_SUFFIX."'});";
|
||||
* $oPage->add_ready_script($sScript);*/
|
||||
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content"]);
|
||||
$bVertical = true;
|
||||
$idx = 0;
|
||||
$aValues = $this->oField->GetCurrentValue();
|
||||
$sId = $this->oField->GetGlobalId();
|
||||
|
||||
// N°4792 - load only the required fields
|
||||
$aFieldsToLoad = [];
|
||||
|
||||
$aComplementAttributeSpec = MetaModel::GetNameSpec($oAllowedValues->GetClass(), FriendlyNameType::COMPLEMENTARY);
|
||||
$sFormatAdditionalField = $aComplementAttributeSpec[0];
|
||||
$aAdditionalField = $aComplementAttributeSpec[1];
|
||||
$bAddingValue = false;
|
||||
|
||||
if (count($aAdditionalField) > 0) {
|
||||
$sClassAllowed = $oAllowedValues->GetClass();
|
||||
$bAddingValue = true;
|
||||
$aFieldsToLoad[$sClassAllowed] = $aAdditionalField;
|
||||
}
|
||||
$sObjectImageAttCode = MetaModel::GetImageAttributeCode($sClassAllowed);
|
||||
if (!empty($sObjectImageAttCode)) {
|
||||
$aFieldsToLoad[$sClassAllowed][] = $sObjectImageAttCode;
|
||||
}
|
||||
$aFieldsToLoad[$sClassAllowed][] = 'friendlyname';
|
||||
$oAllowedValues->OptimizeColumnLoad($aFieldsToLoad);
|
||||
|
||||
$oSelect = SelectUIBlockFactory::MakeForSelectWithLabel($this->oField->GetLabel(), $this->oField->GetDescription(), $this->oField->GetGlobalId());
|
||||
while ($oObj = $oAllowedValues->Fetch()) {
|
||||
$oSelect->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption(
|
||||
$oObj->GetKey(),
|
||||
$oObj->GetName(),
|
||||
in_array($oObj->GetKey(), $aValues, true))
|
||||
);
|
||||
}
|
||||
$oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "radio_$sId", $iObject, "{$sId}_{$iObject}", "radio");
|
||||
$oRadioCustom->AddCSSClass('ibo-input-field-wrapper');
|
||||
$oRadioCustom->GetInput()->SetIsChecked($sSelected);
|
||||
$oRadioCustom->SetBeforeInput(false);
|
||||
$oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox');
|
||||
$oValue->AddSubBlock($oRadioCustom);
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
<<<JS
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("#{$this->oField->GetGlobalId()}").selectize({
|
||||
sortField: 'text',
|
||||
onChange: function(value){
|
||||
|
||||
console.warn('chane');
|
||||
var me = this.\$input;
|
||||
me.trigger("field_change", {
|
||||
id: me.attr("id"),
|
||||
name: me.closest(".form_field").attr("data-field-id"),
|
||||
value: me.val()
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
},
|
||||
inputClass: 'ibo-input-vanilla ibo-input ibo-input-selectize',
|
||||
});
|
||||
$("#{$this->oField->GetGlobalId()}").closest('div').addClass('ibo-input-select-wrapper--with-buttons');
|
||||
$("#{$this->oField->GetGlobalId()}").off("change").on("change", function(){
|
||||
var me = this;
|
||||
|
||||
$(this).closest(".field_set").trigger("field_change", {
|
||||
id: $(me).attr("id"),
|
||||
name: $(me).closest(".form_field").attr("data-field-id"),
|
||||
value: $(me).val()
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
});
|
||||
JS
|
||||
);
|
||||
|
||||
|
||||
$oValue->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
break;
|
||||
default:
|
||||
if ($iCount > $iMaxComboLength) {
|
||||
|
||||
// Auto-complete
|
||||
//
|
||||
$oBlock->AddDataAttribute("input-type", "Combodo\\iTop\\Form\\Field\\SelectObjectField\\Autocomplete");
|
||||
$sEditType = 'autocomplete';
|
||||
$sFieldName = $this->oField->GetGlobalId();
|
||||
$sFieldId = $sFieldName;
|
||||
$sFormPrefix = '';
|
||||
$oWidget = new UIExtKeyWidget($sTargetClass, $sFieldId, '', true);
|
||||
$aArgs = array();
|
||||
$sTitle = $this->oField->GetLabel();
|
||||
|
||||
$oPage = new CaptureWebPage();
|
||||
$sHTMLValue = $oWidget->DisplaySelect($oPage, $iMaxComboLength, false /* $bAllowTargetCreation */, $sTitle, $oSet, $this->oField->GetCurrentValue(), $this->oField->GetMandatory(), $sFieldName, $sFormPrefix, $aArgs);
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard();
|
||||
$oValue->AddSubBlock(new Html($sHTMLValue));
|
||||
$oValue->AddSubBlock(new Html($oPage->GetHtml()));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
|
||||
$oOutput->AddJs($oPage->GetJS());
|
||||
$oOutput->AddJs($oPage->GetReadyJS());
|
||||
foreach ($oPage->GetCSS() as $sCss) {
|
||||
$oOutput->AddCss($sCss);
|
||||
}
|
||||
foreach ($oPage->GetJSFiles() as $sFile) {
|
||||
$oOutput->AddJsFile($sFile);
|
||||
}
|
||||
foreach ($oPage->GetCSSFiles() as $sFile) {
|
||||
$oOutput->AddCssFile($sFile);
|
||||
}
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("#{$this->oField->GetGlobalId()}").off("change").on("change", function(){
|
||||
var me = this;
|
||||
|
||||
$(this).closest(".field_set").trigger("field_change", {
|
||||
id: $(me).attr("id"),
|
||||
name: $(me).closest(".form_field").attr("data-field-id"),
|
||||
value: $(me).val()
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
});
|
||||
EOF
|
||||
);
|
||||
} elseif ($this->oField->GetControlType() == SelectObjectField::CONTROL_RADIO_VERTICAL) {
|
||||
$oBlock->AddDataAttribute("input-type", "Combodo\\iTop\\Form\\Field\\SelectObjectField\\Radio");
|
||||
// Radio buttons (vertical)
|
||||
//
|
||||
$sEditType = 'radio';
|
||||
$bVertical = true;
|
||||
$idx = 0;
|
||||
$bMandatory = $this->oField->GetMandatory();
|
||||
$value = $this->oField->GetCurrentValue();
|
||||
$sId = $this->oField->GetGlobalId();
|
||||
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard();
|
||||
|
||||
while ($oObject = $oSet->Fetch()) {
|
||||
$iObject = $oObject->GetKey();
|
||||
$sLabel = $oObject->Get('friendlyname');
|
||||
if (($iCount == 1) && $bMandatory) {
|
||||
// When there is only once choice, select it by default
|
||||
$sSelected = 'checked';
|
||||
$value = $iObject;
|
||||
} else {
|
||||
$sSelected = ($value == $iObject) ? 'checked' : '';
|
||||
}
|
||||
$oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "radio_$sId", $iObject, "{$sId}_{$iObject}", "radio");
|
||||
$oRadioCustom->AddCSSClass('ibo-input-field-wrapper');
|
||||
$oRadioCustom->GetInput()->SetIsChecked($sSelected);
|
||||
$oRadioCustom->SetBeforeInput(false);
|
||||
$oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox');
|
||||
$oValue->AddSubBlock($oRadioCustom);
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("#{$sId}_{$iObject}").off("change").on("change", function(){
|
||||
$('#{$sId}').val(this.value).trigger('change');
|
||||
});
|
||||
EOF
|
||||
);
|
||||
if ($bVertical)
|
||||
{
|
||||
$oValue->AddSubBlock(new Html("<br>"));
|
||||
}
|
||||
$idx++;
|
||||
}
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden($sId,$value,$sId));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
$oBlock->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
);
|
||||
if ($bVertical) {
|
||||
$oValue->AddSubBlock(new Html("<br>"));
|
||||
}
|
||||
$idx++;
|
||||
}
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden($sId, $value, $sId));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
$oBlock->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("#{$this->oField->GetGlobalId()}").off("change").on("change", function(){
|
||||
var me = this;
|
||||
|
||||
@@ -201,28 +356,25 @@ EOF
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Drop-down select
|
||||
//
|
||||
$oBlock->AddDataAttribute("input-type","Combodo\\iTop\\Form\\Field\\SelectObjectField\\Select");
|
||||
$sEditType = 'select';
|
||||
$oSelect = SelectUIBlockFactory::MakeForSelect("",$this->oField->GetGlobalId());
|
||||
$oSelect->AddCSSClass('ibo-input-select-placeholder');
|
||||
$oBlock->AddSubBlock(UIContentBlockUIBlockFactory::MakeStandard(null,['ibo-input-field-wrapper'])->AddSubBlock($oSelect));
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('',Dict::S('UI:SelectOne'), false ));
|
||||
while ($oObject = $oSet->Fetch())
|
||||
{
|
||||
$iObject = $oObject->GetKey();
|
||||
$sLabel = $oObject->Get('friendlyname');
|
||||
// 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)
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption($iObject,$sLabel, ($this->oField->GetCurrentValue() == $iObject)));
|
||||
}
|
||||
$oBlock->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
);
|
||||
} else {
|
||||
// Drop-down select
|
||||
//
|
||||
$oBlock->AddDataAttribute("input-type", "Combodo\\iTop\\Form\\Field\\SelectObjectField\\Select");
|
||||
$sEditType = 'select';
|
||||
$oSelect = SelectUIBlockFactory::MakeForSelect("", $this->oField->GetGlobalId());
|
||||
$oSelect->AddCSSClass('ibo-input-select-placeholder');
|
||||
$oBlock->AddSubBlock(UIContentBlockUIBlockFactory::MakeStandard(null, ['ibo-input-field-wrapper'])->AddSubBlock($oSelect));
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('', Dict::S('UI:SelectOne'), false));
|
||||
while ($oObject = $oSet->Fetch()) {
|
||||
$iObject = $oObject->GetKey();
|
||||
$sLabel = $oObject->Get('friendlyname');
|
||||
// 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)
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption($iObject, $sLabel, ($this->oField->GetCurrentValue() == $iObject)));
|
||||
}
|
||||
$oBlock->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("#{$this->oField->GetGlobalId()}").selectize({
|
||||
sortField: 'text',
|
||||
onChange: function(value){
|
||||
@@ -238,28 +390,26 @@ EOF
|
||||
});
|
||||
$("#{$this->oField->GetGlobalId()}").closest('div').addClass('ibo-input-select-wrapper--with-buttons');
|
||||
JS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$oOutput->AddHtml((BlockRenderer::RenderBlockTemplates($oBlock)));
|
||||
// JS Form field widget construct
|
||||
$aValidators = array();
|
||||
foreach ($this->oField->GetValidators() as $oValidator) {
|
||||
if ($oValidator::GetName() == 'notemptyextkey') {
|
||||
// The autocomplete widget returns an empty string if the value is undefined (and the select has been aligned with this behavior)
|
||||
$oValidator = new MandatoryValidator();
|
||||
}
|
||||
$aValidators[$oValidator::GetName()] = array(
|
||||
'reg_exp' => $oValidator->GetRegExp(),
|
||||
'message' => Dict::S($oValidator->GetErrorMessage()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$oOutput->AddHtml((BlockRenderer::RenderBlockTemplates($oBlock)));
|
||||
// JS Form field widget construct
|
||||
$aValidators = array();
|
||||
foreach ($this->oField->GetValidators() as $oValidator)
|
||||
{
|
||||
if ($oValidator::GetName() == 'notemptyextkey')
|
||||
{
|
||||
// The autocomplete widget returns an empty string if the value is undefined (and the select has been aligned with this behavior)
|
||||
$oValidator = new MandatoryValidator();
|
||||
}
|
||||
$aValidators[$oValidator::GetName()] = array(
|
||||
'reg_exp' => $oValidator->GetRegExp(),
|
||||
'message' => Dict::S($oValidator->GetErrorMessage())
|
||||
);
|
||||
}
|
||||
$sValidators = json_encode($aValidators);
|
||||
$sFormFieldOptions =
|
||||
<<<EOF
|
||||
$sValidators = json_encode($aValidators);
|
||||
$sFormFieldOptions =
|
||||
<<<EOF
|
||||
{
|
||||
validators: $sValidators,
|
||||
on_validation_callback: function(me, oResult) {
|
||||
@@ -279,14 +429,14 @@ JS
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
;
|
||||
EOF;
|
||||
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").form_field($sFormFieldOptions);
|
||||
EOF
|
||||
);
|
||||
);
|
||||
}
|
||||
switch ($sEditType)
|
||||
{
|
||||
case 'autocomplete':
|
||||
|
||||
@@ -51,6 +51,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
|
||||
{
|
||||
$oOutput = parent::Render();
|
||||
$sFieldClass = get_class($this->oField);
|
||||
\IssueLog::Error($this->oField->GetLabel().':render simple:'.$sFieldClass);
|
||||
|
||||
if ($sFieldClass == 'Combodo\\iTop\\Form\\Field\\HiddenField')
|
||||
{
|
||||
@@ -99,24 +100,22 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
|
||||
switch ($sFieldClass)
|
||||
{
|
||||
case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("",["form-field-content"]);
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content"]);
|
||||
|
||||
$sDateTimeFormat = $this->oField->GetPHPDateTimeFormat();
|
||||
$oFormat = new DateTimeFormat($sDateTimeFormat);
|
||||
$sPlaceHolder = $oFormat->ToPlaceholder();
|
||||
if ($this->oField->GetReadOnly())
|
||||
{
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId()));
|
||||
if ($this->oField->GetReadOnly()) {
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", $this->oField->GetCurrentValue(), $this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(new Html($this->oField->GetCurrentValue()));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$oField = UIContentBlockUIBlockFactory::MakeStandard("", ["field_input_zone", "field_input_datetime", "ibo-input-field-wrapper", "ibo-input-datetime-wrapper"]);
|
||||
$oValue->AddSubBlock($oField);
|
||||
$oField->AddSubBlock(new Html('<input class="date-pick ibo-input ibo-input-date" type="text" placeholder="'.utils::EscapeHtml($sPlaceHolder).'" id="'.$this->oField->GetGlobalId().'" value="'.utils::EscapeHtml($this->oField->GetCurrentValue()).'" autocomplete="off"/>'));
|
||||
$oField->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
}
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\LabelField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("",[""]);
|
||||
@@ -175,8 +174,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
|
||||
$('#{$this->oField->GetGlobalId()}').ckeditor(function(){}, $sJsConfig);
|
||||
EOF
|
||||
);
|
||||
if (($this->oField->GetObject() !== null) && ($this->oField->GetTransactionId() !== null))
|
||||
{
|
||||
if (($this->oField->GetObject() !== null) && ($this->oField->GetTransactionId() !== null)) {
|
||||
$oOutput->AddJs(InlineImage::EnableCKEditorImageUpload($this->oField->GetObject(), utils::GetUploadTempId($this->oField->GetTransactionId())));
|
||||
}
|
||||
}
|
||||
@@ -186,25 +184,21 @@ EOF
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\SelectField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("",["form-field-content","ibo-input-field-wrapper"]);
|
||||
if ($this->oField->GetReadOnly())
|
||||
{
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content", "ibo-input-field-wrapper"]);
|
||||
if ($this->oField->GetReadOnly()) {
|
||||
$aChoices = $this->oField->GetChoices();
|
||||
$sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '' ;
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId()));
|
||||
$sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '';
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", $this->oField->GetCurrentValue(), $this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(new Html($sCurrentLabel));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oSelect = SelectUIBlockFactory::MakeForSelect("",$this->oField->GetGlobalId());
|
||||
} else {
|
||||
$oSelect = SelectUIBlockFactory::MakeForSelect("", $this->oField->GetGlobalId());
|
||||
$oSelect->AddCSSClass('ibo-input-field-wrapper');
|
||||
if ($this->oField->GetMultipleValuesEnabled()) {
|
||||
$oSelect->SetIsMultiple(true);
|
||||
}
|
||||
foreach ($this->oField->GetChoices() as $sChoice => $sLabel)
|
||||
{
|
||||
foreach ($this->oField->GetChoices() as $sChoice => $sLabel) {
|
||||
// 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)
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption($sChoice,$sLabel, ($this->oField->GetCurrentValue() == $sChoice)));
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption($sChoice, $sLabel, ($this->oField->GetCurrentValue() == $sChoice)));
|
||||
}
|
||||
$oValue->AddSubBlock($oSelect);
|
||||
$oValue->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
@@ -212,25 +206,118 @@ EOF
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\RadioField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("",["form-field-content"]);
|
||||
if ($this->oField->GetReadOnly())
|
||||
{
|
||||
case 'Combodo\\iTop\\Form\\Field\\TagSetField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content", "ibo-input-field-wrapper"]);
|
||||
if ($this->oField->GetReadOnly()) {
|
||||
$aChoices = $this->oField->GetChoices();
|
||||
$sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '' ;
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId()));
|
||||
$sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '';
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", $this->oField->GetCurrentValue(), $this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(new Html($sCurrentLabel));
|
||||
} else {
|
||||
$oSelect = SelectUIBlockFactory::MakeForSelect("", $this->oField->GetGlobalId());
|
||||
$oSelect->SetIsMultiple(true);
|
||||
$oSelect->AddCSSClass('ibo-input-field-wrapper');
|
||||
\IssueLog::Error('valeur:'.json_encode($this->oField->GetCurrentValue()));
|
||||
foreach ($this->oField->GetChoices() as $sChoice => $sLabel) {
|
||||
// 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)
|
||||
$oSelect->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption($sChoice, $sLabel, in_array($sChoice, $this->oField->GetCurrentValue()) === true));
|
||||
}
|
||||
$oValue->AddSubBlock($oSelect);
|
||||
$oValue->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("#{$this->oField->GetGlobalId()}").selectize({
|
||||
maxItems: null,
|
||||
sortField: 'text',
|
||||
onChange: function(value){
|
||||
var me = this.\$input;
|
||||
me.trigger("field_change", {
|
||||
id: me.attr("id"),
|
||||
name: me.closest(".form_field").attr("data-field-id"),
|
||||
value: JSON.stringify(me.val())
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
console.warn('chanegement');
|
||||
},
|
||||
});
|
||||
$("#{$this->oField->GetGlobalId()}").closest('div').addClass('ibo-input-select-wrapper--with-buttons');
|
||||
JS
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content"]);
|
||||
if ($this->oField->GetReadOnly()) {
|
||||
$aChoices = $this->oField->GetChoices();
|
||||
$sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '';
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", $this->oField->GetCurrentValue(), $this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(new Html($sCurrentLabel));
|
||||
} else {
|
||||
$aValues = $this->oField->GetCurrentValue();
|
||||
// $oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", implode(',', $this->oField->GetCurrentValue()), $this->oField->GetGlobalId()));
|
||||
$iId = 1;
|
||||
foreach ($this->oField->GetChoices() as $sChoice => $sLabel) {
|
||||
$oCheckBox = InputUIBlockFactory::MakeForInputWithLabel($sLabel, ''.$this->oField->GetGlobalId(), $sChoice, $this->oField->GetGlobalId().'_'.$iId, "checkbox");
|
||||
$oCheckBox->GetInput()->SetIsChecked(in_array($sChoice, $aValues) === true);
|
||||
$oCheckBox->SetBeforeInput(false);
|
||||
$oCheckBox->GetInput()->AddCSSClass('ibo-input--label-right');
|
||||
$oCheckBox->GetInput()->AddCSSClass('ibo-input-checkbox');
|
||||
$oValue->AddSubBlock($oCheckBox);
|
||||
$iId++;
|
||||
}
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("[name={$this->oField->GetGlobalId()}]").off("change").on("change", function(){
|
||||
|
||||
$("[name={$this->oField->GetGlobalId()}]").closest(".field_set").trigger("field_change", {
|
||||
id: $("[name={$this->oField->GetGlobalId()}]").attr("id"),
|
||||
name: $("[name={$this->oField->GetGlobalId()}]").closest(".form_field").attr("data-field-id"),
|
||||
value: $("[name={$this->oField->GetGlobalId()}]").val()
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
});
|
||||
JS
|
||||
);
|
||||
/* $oOutput->AddJs(
|
||||
<<<JS
|
||||
$("[name=checkbox_{$this->oField->GetGlobalId()}]").off("change").on("change", function(){
|
||||
var aValues = [];
|
||||
$("[name=checkbox_{$this->oField->GetGlobalId()}]").each(function(){ if (this.checked){ aValues.push($(this).val()); }});
|
||||
$("#{$this->oField->GetGlobalId()}").val(aValues.toString());
|
||||
|
||||
$("#{$this->oField->GetGlobalId()}").closest(".field_set").trigger("field_change", {
|
||||
id: $("{$this->oField->GetGlobalId()}").attr("id"),
|
||||
name: $("{$this->oField->GetGlobalId()}").closest(".form_field").attr("data-field-id"),
|
||||
value: $("{$this->oField->GetGlobalId()}").val()
|
||||
})
|
||||
.closest('.form_handler').trigger('value_change');
|
||||
});
|
||||
JS
|
||||
);*/
|
||||
|
||||
|
||||
$oValue->AddSubBlock(new Html('<span class="form_validation"></span>'));
|
||||
$oBlock->AddSubBlock($oValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\RadioField':
|
||||
$oValue = UIContentBlockUIBlockFactory::MakeStandard("", ["form-field-content"]);
|
||||
if ($this->oField->GetReadOnly()) {
|
||||
$aChoices = $this->oField->GetChoices();
|
||||
$sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '';
|
||||
$oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("", $this->oField->GetCurrentValue(), $this->oField->GetGlobalId()));
|
||||
$oValue->AddSubBlock(new Html($sCurrentLabel));
|
||||
} else {
|
||||
$bVertical = true;
|
||||
$idx = 0;
|
||||
$bMandatory = $this->oField->GetMandatory();
|
||||
$value = $this->oField->GetCurrentValue();
|
||||
$sId = $this->oField->GetGlobalId();
|
||||
$aChoices = $this->oField->GetChoices();
|
||||
foreach ($aChoices as $sChoice => $sLabel)
|
||||
{
|
||||
foreach ($aChoices as $sChoice => $sLabel) {
|
||||
if ((count($aChoices) == 1) && $bMandatory) {
|
||||
// When there is only once choice, select it by default
|
||||
$sSelected = 'checked';
|
||||
@@ -400,6 +487,8 @@ EOF
|
||||
$("#{$this->oField->GetGlobalId()}").selectize({
|
||||
sortField: 'text',
|
||||
onChange: function(value){
|
||||
|
||||
console.warn('lala');
|
||||
var me = this.\$input;
|
||||
me.closest(".field_set").trigger("field_change", {
|
||||
id: me.attr("id"),
|
||||
@@ -469,8 +558,7 @@ EOF
|
||||
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").form_field($sFormFieldOptions);
|
||||
EOF
|
||||
);
|
||||
switch ($sFieldClass)
|
||||
{
|
||||
switch ($sFieldClass) {
|
||||
case 'Combodo\\iTop\\Form\\Field\\SelectField':
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
@@ -478,6 +566,13 @@ EOF
|
||||
EOF
|
||||
);
|
||||
break;
|
||||
case 'Combodo\\iTop\\Form\\Field\\TagSetField':
|
||||
//case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").form_field('option', 'get_current_value_callback', function(me){console.warn('bobb'); return $(me.element).find('select').val();});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
$oOutput->AddJs(
|
||||
|
||||
Reference in New Issue
Block a user