Source of file InputElementAbstract.php

Size: 1,375 Bytes - Last Modified: 2015-12-22T09:12:14-05:00

../src/View/Helper/InputElementAbstract.php

12345678910111213141516171819202122232425262728293031323334353637
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
38
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
39
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
40
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
41
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
42
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
4344
Covered by 5 test(s):
  • MvcLite\ViewHelperInputCheckboxTest::testRender with data set #0
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputSelectTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextareaTest::testRender with data set #0
454647484950515253545556
Covered by 2 test(s):
  • MvcLite\ViewHelperInputPasswordTest::testRender with data set #0
  • MvcLite\ViewHelperInputTextTest::testRender with data set #0
575859
<?php
/**
 * Base Form Element Helper class
 *
 * @category    PHP
 * @package     MvcLite
 * @subpackage  View\Helper
 * @since       File available since release 3.3.x
 * @author      Cory Collier <corycollier@corycollier.com>
 */

namespace MvcLite\View\Helper;

use MvcLite\View\HelperAbstract as HelperAbstract;

/**
 * Base Form Element Helper class
 *
 * @category    PHP
 * @package     MvcLite
 * @subpackage  View\Helper
 * @since       Class available since release 3.3.x
 * @author      Cory Collier <corycollier@corycollier.com>
 */
abstract class InputElementAbstract extends HelperAbstract
{
    /**
     * Gets the default attributes.
     *
     * @param string $name The name of the element.
     *
     * @return string The resulting array of attributes.
     */
    public function getDefaultAttribs($name, $type)
    {
        $results = [
            'id'    => $name,
            'type'  => $type,
            'name'  => $name,
            'class' => 'form-control',
            'label' => ucwords($name),
        ];

        return $results;
    }

    /**
     * Standard template for form elements.
     *
     * This template works for all input[type=$type] elements.
     *
     * @return string The resulting html.
     */
    public function getStandardTemplate()
    {
        return '<label for="!id">!label</label><input!attribs />';
    }
}