text.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * HTML class for a text field
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * LICENSE: This source file is subject to version 3.01 of the PHP license
  9. * that is available through the world-wide-web at the following URI:
  10. * http://www.php.net/license/3_01.txt If you did not receive a copy of
  11. * the PHP License and are unable to obtain it through the web, please
  12. * send a note to license@php.net so we can mail you a copy immediately.
  13. *
  14. * @category HTML
  15. * @package HTML_QuickForm
  16. * @author Adam Daniel <adaniel1@eesus.jnj.com>
  17. * @author Bertrand Mansion <bmansion@mamasam.com>
  18. * @copyright 2001-2009 The PHP Group
  19. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  20. * @version CVS: $Id: text.php,v 1.7 2009/04/04 21:34:04 avb Exp $
  21. * @link http://pear.php.net/package/HTML_QuickForm
  22. */
  23. /**
  24. * Base class for <input /> form elements
  25. */
  26. //require_once 'HTML/QuickForm/input.php';
  27. /**
  28. * HTML class for a text field
  29. *
  30. * @category HTML
  31. * @package HTML_QuickForm
  32. * @author Adam Daniel <adaniel1@eesus.jnj.com>
  33. * @author Bertrand Mansion <bmansion@mamasam.com>
  34. * @version Release: 3.2.11
  35. * @since 1.0
  36. */
  37. class HTML_QuickForm_text extends HTML_QuickForm_input
  38. {
  39. /**
  40. * Class constructor
  41. *
  42. * @param string $elementName (optional)Input field name attribute
  43. * @param string $elementLabel (optional)Input field label
  44. * @param mixed $attributes (optional)Either a typical HTML attribute string
  45. * or an associative array
  46. * @since 1.0
  47. * @access public
  48. * @return void
  49. */
  50. function HTML_QuickForm_text($elementName = null, $elementLabel = null, $attributes = null)
  51. {
  52. if (isset($attributes) && is_array($attributes) && !empty($attributes['class'])) {
  53. $attributes['class'] .= $attributes['class'].' form-control';
  54. } else {
  55. if (empty($attributes['class'])) {
  56. $attributes = array('class' => 'form-control');
  57. }
  58. }
  59. HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
  60. $this->_persistantFreeze = true;
  61. $this->setType('text');
  62. } //end constructor
  63. // }}}
  64. // {{{ setSize()
  65. /**
  66. * Sets size of text field
  67. *
  68. * @param string $size Size of text field
  69. * @since 1.3
  70. * @access public
  71. * @return void
  72. */
  73. function setSize($size)
  74. {
  75. $this->updateAttributes(array('size'=>$size));
  76. } //end func setSize
  77. // }}}
  78. // {{{ setMaxlength()
  79. /**
  80. * Sets maxlength of text field
  81. *
  82. * @param string $maxlength Maximum length of text field
  83. * @since 1.3
  84. * @access public
  85. * @return void
  86. */
  87. function setMaxlength($maxlength)
  88. {
  89. $this->updateAttributes(array('maxlength' => $maxlength ));
  90. }
  91. }