mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Form : Added LabelField class for forms.
SVN:trunk[3959]
This commit is contained in:
@@ -26,6 +26,7 @@ require_once APPROOT . 'sources/form/field/field.class.inc.php';
|
|||||||
require_once APPROOT . 'sources/form/field/subformfield.class.inc.php';
|
require_once APPROOT . 'sources/form/field/subformfield.class.inc.php';
|
||||||
require_once APPROOT . 'sources/form/field/textfield.class.inc.php';
|
require_once APPROOT . 'sources/form/field/textfield.class.inc.php';
|
||||||
require_once APPROOT . 'sources/form/field/hiddenfield.class.inc.php';
|
require_once APPROOT . 'sources/form/field/hiddenfield.class.inc.php';
|
||||||
|
require_once APPROOT . 'sources/form/field/labelfield.class.inc.php';
|
||||||
require_once APPROOT . 'sources/form/field/stringfield.class.inc.php';
|
require_once APPROOT . 'sources/form/field/stringfield.class.inc.php';
|
||||||
require_once APPROOT . 'sources/form/field/textareafield.class.inc.php';
|
require_once APPROOT . 'sources/form/field/textareafield.class.inc.php';
|
||||||
require_once APPROOT . 'sources/form/field/multiplechoicesfield.class.inc.php';
|
require_once APPROOT . 'sources/form/field/multiplechoicesfield.class.inc.php';
|
||||||
|
|||||||
32
sources/form/field/labelfield.class.inc.php
Normal file
32
sources/form/field/labelfield.class.inc.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Copyright (C) 2010-2016 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;
|
||||||
|
|
||||||
|
use \Combodo\iTop\Form\Field\TextField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of LabelField
|
||||||
|
*
|
||||||
|
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||||
|
*/
|
||||||
|
class LabelField extends TextField
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,6 +40,7 @@ class BsFormRenderer extends FormRenderer
|
|||||||
{
|
{
|
||||||
parent::__construct($oForm);
|
parent::__construct($oForm);
|
||||||
$this->AddSupportedField('HiddenField', 'BsSimpleFieldRenderer');
|
$this->AddSupportedField('HiddenField', 'BsSimpleFieldRenderer');
|
||||||
|
$this->AddSupportedField('LabelField', 'BsSimpleFieldRenderer');
|
||||||
$this->AddSupportedField('StringField', 'BsSimpleFieldRenderer');
|
$this->AddSupportedField('StringField', 'BsSimpleFieldRenderer');
|
||||||
$this->AddSupportedField('TextAreaField', 'BsSimpleFieldRenderer');
|
$this->AddSupportedField('TextAreaField', 'BsSimpleFieldRenderer');
|
||||||
$this->AddSupportedField('SelectField', 'BsSimpleFieldRenderer');
|
$this->AddSupportedField('SelectField', 'BsSimpleFieldRenderer');
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class BsSimpleFieldRenderer extends FieldRenderer
|
|||||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
||||||
if ($this->oField->GetLabel() !== '')
|
if ($this->oField->GetLabel() !== '')
|
||||||
{
|
{
|
||||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
|
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||||
}
|
}
|
||||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||||
$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('<input type="text" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" maxlength="255" />');
|
||||||
@@ -69,7 +69,7 @@ class BsSimpleFieldRenderer extends FieldRenderer
|
|||||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
||||||
if ($this->oField->GetLabel() !== '')
|
if ($this->oField->GetLabel() !== '')
|
||||||
{
|
{
|
||||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
|
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||||
}
|
}
|
||||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||||
$oOutput->AddHtml('<textarea id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" class="form-control" rows="8">' . $this->oField->GetCurrentValue() . '</textarea>');
|
$oOutput->AddHtml('<textarea id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" class="form-control" rows="8">' . $this->oField->GetCurrentValue() . '</textarea>');
|
||||||
@@ -95,7 +95,7 @@ EOF
|
|||||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
||||||
if ($this->oField->GetLabel() !== '')
|
if ($this->oField->GetLabel() !== '')
|
||||||
{
|
{
|
||||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
|
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||||
}
|
}
|
||||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||||
$oOutput->AddHtml('<select id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" ' . ( ($this->oField->GetMultipleValuesEnabled()) ? 'multiple' : '' ) . ' class="form-control">');
|
$oOutput->AddHtml('<select id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" ' . ( ($this->oField->GetMultipleValuesEnabled()) ? 'multiple' : '' ) . ' class="form-control">');
|
||||||
@@ -117,7 +117,7 @@ EOF
|
|||||||
|
|
||||||
if ($this->oField->GetLabel() !== '')
|
if ($this->oField->GetLabel() !== '')
|
||||||
{
|
{
|
||||||
$oOutput->AddHtml('<div><label class="control-label">' . $this->oField->GetLabel() . '</label></div>');
|
$oOutput->AddHtml('<div><label class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label></div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||||
@@ -154,6 +154,20 @@ EOF
|
|||||||
{
|
{
|
||||||
switch ($sFieldClass)
|
switch ($sFieldClass)
|
||||||
{
|
{
|
||||||
|
case 'Combodo\\iTop\\Form\\Field\\LabelField':
|
||||||
|
$oOutput->AddHtml('<div class="form-group">');
|
||||||
|
// Showing label / value only if read-only but not hidden
|
||||||
|
if (!$this->oField->GetHidden())
|
||||||
|
{
|
||||||
|
if ($this->oField->GetLabel() !== '')
|
||||||
|
{
|
||||||
|
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||||
|
}
|
||||||
|
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('</div>');
|
||||||
|
}
|
||||||
|
$oOutput->AddHtml('</div>');
|
||||||
|
break;
|
||||||
|
|
||||||
case 'Combodo\\iTop\\Form\\Field\\StringField':
|
case 'Combodo\\iTop\\Form\\Field\\StringField':
|
||||||
case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
|
case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
|
||||||
$bEncodeHtmlEntities = (($sFieldClass === 'Combodo\\iTop\\Form\\Field\\TextAreaField') && ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML)) ? false : true;
|
$bEncodeHtmlEntities = (($sFieldClass === 'Combodo\\iTop\\Form\\Field\\TextAreaField') && ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML)) ? false : true;
|
||||||
@@ -164,7 +178,7 @@ EOF
|
|||||||
{
|
{
|
||||||
if ($this->oField->GetLabel() !== '')
|
if ($this->oField->GetLabel() !== '')
|
||||||
{
|
{
|
||||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
|
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||||
}
|
}
|
||||||
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetCurrentValue(), $bEncodeHtmlEntities)->AddHtml('</div>');
|
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetCurrentValue(), $bEncodeHtmlEntities)->AddHtml('</div>');
|
||||||
}
|
}
|
||||||
@@ -183,7 +197,7 @@ EOF
|
|||||||
{
|
{
|
||||||
if ($this->oField->GetLabel() !== '')
|
if ($this->oField->GetLabel() !== '')
|
||||||
{
|
{
|
||||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">' . $this->oField->GetLabel() . '</label>');
|
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||||
}
|
}
|
||||||
$oOutput->AddHtml('<div class="form-control-static">' . $sFieldValue . '</div>');
|
$oOutput->AddHtml('<div class="form-control-static">' . $sFieldValue . '</div>');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user