FoundationSubmitElement.class.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class Staple_Form_FoundationSubmitElement 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. return ' <input type="submit" '.$this->getClassString().' id="'.$this->escape($this->id).'" name="'.$this->escape($this->name).'" value="'.$this->escape($this->value).'"'.$this->getAttribString().">\n";
  18. }
  19. /* (non-PHPdoc)
  20. * @see Staple_Form_Element::label()
  21. */
  22. public function label()
  23. {
  24. return " <label for=\"".$this->escape($this->id)."\"".$this->getClassString().">".$this->label."</label>\n";
  25. }
  26. public function build()
  27. {
  28. $buf = '';
  29. $view = FORMS_ROOT.'/fields/FoundationSubmitElement.phtml';
  30. if(file_exists($view))
  31. {
  32. ob_start();
  33. include $view;
  34. $buf = ob_get_contents();
  35. ob_end_clean();
  36. }
  37. else
  38. {
  39. $classes = $this->getClassString();
  40. $buf .= "<div class=\"row\">\n";
  41. $buf .= "<div class=\"small-12 columns\">\n";
  42. $buf .= $this->field();
  43. $buf .= "</div>\n";
  44. $buf .= "</div>\n";
  45. }
  46. return $buf;
  47. }
  48. }