FoundationButtonElement.class.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class Staple_Form_FoundationButtonElement extends Staple_Form_Element
  3. {
  4. public function __construct($name, $value=NULL, $label = NULL, $id = NULL, array $attrib = array())
  5. {
  6. parent::__construct($name,$label,$id,$attrib);
  7. if(isset($value))
  8. {
  9. $this->value = $value;
  10. }
  11. }
  12. /* (non-PHPdoc)
  13. * @see Staple_Form_Element::field()
  14. */
  15. public function field()
  16. {
  17. $classes = $this->getClassString();
  18. echo $classes;
  19. return ' <input type="button" class="button" id="'.$this->escape($this->id).'" name="'.$this->escape($this->name).'" value="'.$this->escape($this->value).'"'.$this->getAttribString().">\n";
  20. }
  21. /* (non-PHPdoc)
  22. * @see Staple_Form_Element::label()
  23. */
  24. public function label()
  25. {
  26. return " <label for=\"".$this->escape($this->id)."\"".$this->getClassString().">".$this->label."</label>\n";
  27. }
  28. public function build()
  29. {
  30. $buf = '';
  31. $view = FORMS_ROOT.'/fields/FoundationButtonElement.phtml';
  32. if(file_exists($view))
  33. {
  34. ob_start();
  35. include $view;
  36. $buf = ob_get_contents();
  37. ob_end_clean();
  38. }
  39. else
  40. {
  41. $buf .= "<div class=\"row\">\n";
  42. $buf .= "<div class=\"small-12 columns\">\n";
  43. $buf .= $this->field();
  44. $buf .= "</div>\n";
  45. $buf .= "</div>\n";
  46. }
  47. return $buf;
  48. }
  49. }