mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Customer portal : Form - Hiding templates when there is none in order to optimize form space (Actually hiding SubForm when there is only HiddenField)
SVN:trunk[4092]
This commit is contained in:
@@ -362,8 +362,10 @@ EOF
|
||||
<<<EOF
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<button type="button" class="btn btn-sm btn-danger" id="{$sButtonRemoveId}" title="{$sLabelRemove}" disabled><span class="glyphicon glyphicon-minus"></span></button>
|
||||
<button type="button" class="btn btn-sm btn-default" id="{$sButtonAddId}" title="{$sLabelAdd}"><span class="glyphicon glyphicon-plus"></span></button>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-sm btn-danger" id="{$sButtonRemoveId}" title="{$sLabelRemove}" disabled><span class="glyphicon glyphicon-minus"></span></button>
|
||||
<button type="button" class="btn btn-sm btn-default" id="{$sButtonAddId}" title="{$sLabelAdd}"><span class="glyphicon glyphicon-plus"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
EOF
|
||||
|
||||
@@ -29,6 +29,23 @@ class BsSubFormFieldRenderer extends FieldRenderer
|
||||
{
|
||||
$oOutput = new RenderingOutput();
|
||||
|
||||
// Checking if subform has visible fields
|
||||
$bHasVisibleFields = false;
|
||||
foreach ($this->oField->GetForm()->GetFields() as $oSubFormField)
|
||||
{
|
||||
$sSubFormFieldClass = get_class($oSubFormField);
|
||||
// Note : This is a dirty hack for templates. As they show a label when there is no template, we have to detect it...
|
||||
if (($sSubFormFieldClass !== 'Combodo\iTop\Form\Field\HiddenField') && ($oSubFormField->GetId() !== '_no_template_'))
|
||||
{
|
||||
$bHasVisibleFields = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Showing subform if there are visible fields
|
||||
if (!$bHasVisibleFields)
|
||||
{
|
||||
$oOutput->AddHtml('<div class="hidden">');
|
||||
}
|
||||
if (($this->oField->GetLabel() !== null) && ($this->oField->GetLabel() !== ''))
|
||||
{
|
||||
$oOutput->AddHtml('<fieldset><legend>' . $this->oField->GetLabel() . '</legend>');
|
||||
@@ -39,6 +56,10 @@ class BsSubFormFieldRenderer extends FieldRenderer
|
||||
{
|
||||
$oOutput->AddHtml('</fieldset>');
|
||||
}
|
||||
if (!$bHasVisibleFields)
|
||||
{
|
||||
$oOutput->AddHtml('</div>');
|
||||
}
|
||||
|
||||
$oRenderer = new BsFormRenderer($this->oField->GetForm());
|
||||
$aRenderRes = $oRenderer->Render();
|
||||
|
||||
Reference in New Issue
Block a user