label.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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, $attributes = null) {
  31. $this->HTML_QuickForm_static(null, $label, $text, $attributes);
  32. $this->_type = 'html';
  33. }
  34. // }}}
  35. // {{{ accept()
  36. /**
  37. * Accepts a renderer
  38. *
  39. * @param HTML_QuickForm_Renderer renderer object (only works with Default renderer!)
  40. * @access public
  41. * @return void
  42. */
  43. function accept(&$renderer, $required=false, $error=null) {
  44. $renderer->renderHtml($this);
  45. }
  46. function toHtml() {
  47. $for = $this->getLabelFor();
  48. return '<div class="control-group ">
  49. <label class="control-label"'.(empty($for)?'':' for="'.$for.'"').'>'.$this->getLabel().'</label>
  50. <div class="controls">
  51. '.HTML_QuickForm_static::toHtml().'
  52. </div>
  53. </div>
  54. ';
  55. } //end func toHtml
  56. // }}}
  57. } //end class HTML_QuickForm_html