Contents

PasswordTextBox

PasswordTextBox captures password text obscuring user input using the password HTML input element.

It extends TextBox and so includes all of it's properties and behaviours but adds no additional ones.

<?php

namespace Rhubarb\Leaf\Controls\Common\Examples\Text\PasswordTextBox;

use Rhubarb\Leaf\Leaves\Leaf;

class PasswordTextBox extends Leaf
{
    /**
    * @var PasswordTextBoxModel
    */
    protected $model;
    
    protected function getViewClass()
    {
        return PasswordTextBoxView::class;
    }
    
    protected function createModel()
    {
        return new PasswordTextBoxModel();
    }
}
                                    
<?php

namespace Rhubarb\Leaf\Controls\Common\Examples\Text\PasswordTextBox;

use Rhubarb\Leaf\Leaves\LeafModel;

class PasswordTextBoxModel extends LeafModel
{
    public $password;
}
                                    
<?php

namespace Rhubarb\Leaf\Controls\Common\Examples\Text\PasswordTextBox;

use Rhubarb\Leaf\Views\View;
use Rhubarb\Leaf\Controls\Common\Text\PasswordTextBox;

class PasswordTextBoxView extends View
{
    /**
    * @var PasswordTextBoxModel
    */
    protected $model;

    protected function createSubLeaves()
    {
        $this->registerSubLeaf(
            $password = new PasswordTextBox("password")
        );

        $password->setMaxLength(15);
    }

    protected function printViewContent()
    {
        print $this->leaves["password"];
    }
}