PHP code example of tavy315 / twitter-bootstrap-zend-form-decorator

1. Go to this page and download the library: Download tavy315/twitter-bootstrap-zend-form-decorator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tavy315 / twitter-bootstrap-zend-form-decorator example snippets



class My_Bootstrap_Form extends \Bootstrap\InlineForm
{
    public function init()
    {
        $this->setIsArray(true);
        $this->setElementsBelongTo('bootstrap');

        $this->_addClassNames('well');

        $this->addElement('text', 'text', array(
            'placeholder'   => 'E-mail',
            'prepend'       => '@',
            'class'         => 'focused'
        ));

        $this->addElement('password', 'password', array(
            'placeholder' => 'Password'
        ));

        $this->addElement('button', 'submit', array(
            'label'         => 'Login',
            'type'          => 'submit',
            'buttonType'    => 'success',
            'icon'          => 'ok',
            'escape'        => false
        ));
    }
}


class My_Vertical_Form extends \Bootstrap\VerticalForm
{
    public function init()
    {
        // Do your stuff here
    }
}


class My_Horizontal_Form extends \Bootstrap\HorizontalForm
{
    public function init()
    {
        // Do your stuff here
    }
}


class My_Inline_Form extends \Bootstrap\InlineForm
{
    public function init()
    {
        // Do your stuff here
    }
}



// Normal search form
$searchForm = new \Bootstrap\SearchForm(array(
    'renderInNavBar' => false,
    'inputName'      => 'q',
    'submitLabel'    => 'Search!'
));

echo $searchForm;

// Navigation bar search form
$mavbarSearchForm = new \Bootstrap\SearchForm(array(
    'renderInNavBar' => true,
    'pullItRight'    => true,
    'inputName'      => 'q',
    'submitLabel'    => 'Search!'
));

echo $navbarSearchForm;


class My_Bootstrap_Form extends \Bootstrap\HorizontalForm
{
    public function init()
    {
        $this->addElement('text', 'email', array(
            'label' => 'E-mail'
        ));

        $this->addElement('text', 'password', array(
            'label' => 'Password'
        ));

        $this->addDisplayGroup(
            array('email', 'password'),
            'login',
            array(
                'legend' => 'Account info'
            )
        );
    }
}


class My_Bootstrap_Form extends \Bootstrap\VerticalForm
{
    public function init()
    {
        // All the other form stuff

        $this->addElement('submit', 'submit', array(
            'buttonType' => \Bootstrap\Form\Element\Submit::BUTTON_SUCCESS,
            'disabled'   => true,
            'label'      => 'Send e-mail!'
        ));
    }
}


class My_Bootstrap_Form extends \Bootstrap\HorizontalForm
{
    public function init()
    {
        // All the other form stuff

        $this->addElement('button', 'submit', array(
            'label'      => 'Send e-mail!',
            'buttonType' => \Bootstrap\Form\Element\Submit::BUTTON_SUCCESS,
            'icon'       => 'ok',
            'whiteIcon'  => true,
            'iconPosition' => \Bootstrap\Form\Element\Button::ICON_POSITION_RIGHT
        ));
    }
}


class My_Bootstrap_Form extends \Bootstrap\HorizontalForm
{
    public function init()
    {
        $this->addElement('button', 'submit', array(
            'label'         => 'Submit!',
            'type'          => 'submit'
        ));

        $this->addElement('button', 'reset', array(
            'label'         => 'Reset',
            'type'          => 'reset'
        ));

        $this->addDisplayGroup(
            array('submit', 'reset'),
            'actions',
            array(
                'disableLoadDefaultDecorators' => true,
                'decorators' => array('Actions')
            )
        );
    }
}


class My_Bootstrap_Form extends \Bootstrap\HorizontalForm
{
    public function init()
    {
        // Some text
        $this->addElement('text', 'input1', array(
            'label'   => 'E-mail',
            'prepend' => '@'
        ));

        // A checkbox
        $this->addElement('text', 'input2', array(
            'label' => '2nd E-mail',
            'prepend' => array(
                'name' => 'internalCheckbox1',
                'active' => true
            )
        ));

        // A glyphicon
        $this->addElement('text', 'input2', array(
            'label' => '2nd E-mail',
            'prepend' => '<i class="icon-envelope"></i>'
        ));
        
        // A submit button
        $submitButton = $this->createElement('button', 'addButton', array(
            'label' => 'Add'
        );
        
        $this->addElement('text', 'input2', array(
            'label' => '2nd E-mail',
            'prepend' => $submitButton
        ));
    }
}


class My_Bootstrap_Form extends \Bootstrap\HorizontalForm
{
    public function init()
    {
        // Some text
        $this->addElement('text', 'input1', array(
            'label'     => 'E-mail',
            'dimension' => 5
        ));
    }
}

<!-- /application/layouts/scripts/default.phtml -->
 $this->headLink()->appendStylesheet('/css/bootstrap.css');