CustomFields : Bootstrap integration

SVN:trunk[3945]
This commit is contained in:
Guillaume Lajarige
2016-03-11 14:34:16 +00:00
parent 7ea5176b56
commit 44ba3d7bf8
3 changed files with 16 additions and 17 deletions

View File

@@ -4024,15 +4024,14 @@ class AttributeExternalKey extends AttributeDBFieldVoid
$oFormField = new $sFormFieldClass($this->GetCode());
}
// Setting choices regarding the field dependencies
$aFieldDependencies = $this->GetPrerequisiteAttributes();
// Field dependencies
if (!empty($aFieldDependencies))
{
$oTmpAttDef = $this;
$oTmpField = $oFormField;
$oFormField->SetOnFinalizeCallback(function() use ($oTmpField, $oTmpAttDef, $oObject)
{
//$oTmpField = $oForm->GetField($sFieldId);
$oTmpField->SetChoices($oTmpAttDef->GetAllowedValues($oObject->ToArgsForQuery()));
});
}
@@ -4040,7 +4039,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
{
$oFormField->SetChoices($this->GetAllowedValues($oObject->ToArgsForQuery()));
}
// If ExtKey is mandatory, we add a validator to ensure that the value 0 is not selected
if ($oObject->GetAttributeFlags($this->GetCode()) & OPT_ATT_MANDATORY)
{
@@ -6561,7 +6560,7 @@ class AttributeCustomFields extends AttributeDefinition
$oFormField->SetForm($this->GetForm($oObject));
}
parent::MakeFormField($oObject, $oFormField);
return $oFormField;
}

View File

@@ -59,9 +59,7 @@ class BsSimpleFieldRenderer extends FieldRenderer
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
}
$oOutput->AddHtml('<div class="help-block"></div>');
$oOutput->AddHtml('<input type="text" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="');
$oOutput->AddHtml($this->oField->GetCurrentValue(), true);
$oOutput->AddHtml('" class="form-control" maxlength="255" />');
$oOutput->AddHtml('<input type="text" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" maxlength="255" />');
$oOutput->AddHtml('</div>');
break;
@@ -139,9 +137,7 @@ EOF
break;
case 'Combodo\\iTop\\Form\\Field\\HiddenField':
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="');
$oOutput->AddHtml($this->oField->GetCurrentValue(), true);
$oOutput->AddHtml('"/>');
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
break;
}
}
@@ -170,13 +166,9 @@ EOF
{
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
}
$oOutput->AddHtml('<div class="form-control-static">');
$oOutput->AddHtml($this->oField->GetCurrentValue(), $bEncodeHtmlEntities);
$oOutput->AddHtml('</div>');
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetCurrentValue(), $bEncodeHtmlEntities)->AddHtml('</div>');
}
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="');
$oOutput->AddHtml($this->oField->GetCurrentValue(), true);
$oOutput->AddHtml('" class="form-control" />');
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
$oOutput->AddHtml('</div>');
break;

View File

@@ -29,8 +29,16 @@ class BsSubFormFieldRenderer extends FieldRenderer
{
$oOutput = new RenderingOutput();
$oOutput->AddHtml('<div id="fieldset_'.$this->oField->GetGlobalId().'">');
if (($this->oField->GetLabel() !== null) && ($this->oField->GetLabel() !== ''))
{
$oOutput->AddHtml('<fieldset><legend>' . $this->oField->GetLabel() . '</legend>');
}
$oOutput->AddHtml('<div id="fieldset_' . $this->oField->GetGlobalId() . '">');
$oOutput->AddHtml('</div>');
if (($this->oField->GetLabel() !== null) && ($this->oField->GetLabel() !== ''))
{
$oOutput->AddHtml('</fieldset>');
}
$oRenderer = new BsFormRenderer($this->oField->GetForm());
$aRenderRes = $oRenderer->Render();