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);
    }
}

Re: selectWithLabel and textareaWithLabel classes for form.inc.php

Excellent.  Perhaps we can create a section for people to upload new controls like this.  That is exactly the type of thing that the HTML controls collection was intended to be... a community built class library for "smart controls" that integrate easily with xajax.

Thank you for your contribution!

// Joe

xajax Developer
Connect to me on LinkedIn:
http://www.linkedin.com/in/calledtoconstruct

Re: selectWithLabel and textareaWithLabel classes for form.inc.php

it's a pleasure to have contributed.

Ludwig