Topic: selectWithLabel and textareaWithLabel classes for form.inc.php
Hi to everyone,
I've been using xajax for more than a year and I must congratulate the team for the effort they have put into developing this excellent ajax framework.
I would like to contribute with this 2 classes I have added to form.inc.php which may be useful to some.:
class clsSelectWithLabel extends clsSelect
{
var $objLabel;
var $sWhere;
var $objBreak;
function clsSelectWithLabel($sLabel, $sWhere, $aConfiguration=array())
{
clsSelect::clsSelect($aConfiguration);
$this->objLabel = new clsLabel(array(
'child' => new clsLiteral($sLabel)
));
$this->objLabel->setControl($this);
$this->sWhere = $sWhere;
$this->objBreak = new clsBr();
}
function printHTML($sIndent='')
{
if ('left' == $this->sWhere || 'above' == $this->sWhere)
$this->objLabel->printHTML($sIndent);
if ('above' == $this->sWhere)
$this->objBreak->printHTML($sIndent);
clsSelect::printHTML($sIndent);
if ('below' == $this->sWhere)
$this->objBreak->printHTML($sIndent);
if ('right' == $this->sWhere || 'below' == $this->sWhere)
$this->objLabel->printHTML($sIndent);
}
}
class clsTextAreaWithLabel extends clsTextArea
{
var $objLabel;
var $sWhere;
var $objBreak;
function clsTextAreaWithLabel($sLabel, $sWhere, $aConfiguration=array())
{
clsTextArea::clsTextArea($aConfiguration);
$this->objLabel = new clsLabel(array(
'child' => new clsLiteral($sLabel)
));
$this->objLabel->setControl($this);
$this->sWhere = $sWhere;
$this->objBreak = new clsBr();
}
function printHTML($sIndent='')
{
if ('left' == $this->sWhere || 'above' == $this->sWhere)
$this->objLabel->printHTML($sIndent);
if ('above' == $this->sWhere)
$this->objBreak->printHTML($sIndent);
clsTextArea::printHTML($sIndent);
if ('below' == $this->sWhere)
$this->objBreak->printHTML($sIndent);
if ('right' == $this->sWhere || 'below' == $this->sWhere)
$this->objLabel->printHTML($sIndent);
}
}