label.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. {
  32. $this->HTML_QuickForm_static(null, $label, $text, $attributes);
  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. $id = $this->getAttribute('id');
  51. $idCondition = null;
  52. if (!empty($id)) {
  53. $idCondition = 'id="'.$id.'"';
  54. }
  55. return '<div class="form-group" '.$idCondition.' >
  56. <label class="col-sm-2 control-label">'.$this->getLabel().'</label>
  57. <div class="col-sm-10">
  58. '.HTML_QuickForm_static::toHtml().'
  59. </div>
  60. </div>';
  61. }
  62. }