. */ class Staple_Form_TextElement extends Staple_Form_Element { /** * Size of the text field. * @var int */ protected $size; /** * Maxlength of the textfield. * @var int */ protected $max; /** * @return the $size */ public function getSize() { return $this->size; } /** * @return the $max */ public function getMax() { return $this->max; } /** * @param int $size */ public function setSize($size) { $this->size = (int)$size; return $this; } /** * @param int $max */ public function setMax($max) { $this->max = (int)$max; return $this; } /** * Build the field label. * @see Staple_Form_Element::label() * @return string */ public function label() { return ' \n"; } /** * Build the field itself. * @see Staple_Form_Element::field() * @return string */ public function field() { $size = ''; $max = ''; if(isset($this->size)) { $size = ' size="'.((int)$this->size).'"'; } if(isset($this->max)) { $max = ' maxlength="'.((int)$this->max).'"'; } return ' getAttribString().'>'."\n"; } /** * Build the form field. * @see Staple_Form_Element::build() * @return string */ public function build() { $buf = ''; $view = FORMS_ROOT.'/fields/TextElement.phtml'; if(file_exists($view)) { ob_start(); include $view; $buf = ob_get_contents(); ob_end_clean(); } else { $this->addClass('form_element'); $this->addClass('element_text'); $classes = $this->getClassString(); $buf .= "escape($this->id)."_element\">\n"; $buf .= $this->label(); $buf .= $this->field(); $buf .= $this->instructions(); $buf .= "\n"; } return $buf; } }