Button.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ cB9nF4R3PEib5Kll5XE9PmRRR5lKxvF/gdkl7k0wjhI=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.3
  11. */
  12. /**
  13. * button form element generator class
  14. */
  15. namespace Cube\Form\Element;
  16. use Cube\Form\Element;
  17. class Button extends Element
  18. {
  19. /**
  20. *
  21. * type of element - override the variable from the parent class
  22. *
  23. * @var string
  24. */
  25. protected $_element = 'button';
  26. /**
  27. *
  28. * class constructor
  29. *
  30. * @param string $name
  31. */
  32. public function __construct($name)
  33. {
  34. parent::__construct($this->_element, $name);
  35. }
  36. /**
  37. *
  38. * get translated button value
  39. *
  40. * @return string
  41. */
  42. public function getValue()
  43. {
  44. $value = parent::getValue();
  45. return $this->getTranslate()->_($value);
  46. }
  47. /**
  48. *
  49. * render the form element
  50. *
  51. * @return string
  52. */
  53. public function render()
  54. {
  55. $value = $this->getValue();
  56. return '<button type="' . $this->_type . '" name="' . $this->_name . '" '
  57. . $this->renderAttributes() . '>'
  58. . $value
  59. . '</button>';
  60. }
  61. }