label.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * HTML class for static data
  4. * @example $form->addElement('label', 'My label', 'Content');
  5. */
  6. require_once 'HTML/QuickForm/static.php';
  7. /**
  8. * A pseudo-element used for adding raw HTML to form
  9. *
  10. * Intended for use with the default renderer only, template-based
  11. * ones may (and probably will) completely ignore this
  12. *
  13. * @category HTML
  14. * @package HTML_QuickForm
  15. * @author Alexey Borzov <avb@php.net>
  16. * @version Release: 3.2.11
  17. * @since 3.0
  18. * @deprecated Please use the templates rather than add raw HTML via this element
  19. */
  20. class HTML_QuickForm_label extends HTML_QuickForm_static
  21. {
  22. // {{{ constructor
  23. /**
  24. * Class constructor
  25. *
  26. * @param string $text raw HTML to add
  27. * @access public
  28. * @return void
  29. */
  30. function HTML_QuickForm_label($label = null, $text = null)
  31. {
  32. $this->HTML_QuickForm_static(null, $label, $text);
  33. $this->_type = 'html';
  34. }
  35. // }}}
  36. // {{{ accept()
  37. /**
  38. * Accepts a renderer
  39. *
  40. * @param HTML_QuickForm_Renderer renderer object (only works with Default renderer!)
  41. * @access public
  42. * @return void
  43. */
  44. function accept(&$renderer, $required = false, $error = null)
  45. {
  46. $renderer->renderHtml($this);
  47. }
  48. function toHtml()
  49. {
  50. return '<div class="control-group">
  51. <label class="control-label">'.$this->getLabel().'</label>
  52. <div class="controls">
  53. '.HTML_QuickForm_static::toHtml().'
  54. </div>
  55. </div>
  56. ';
  57. }
  58. }