4 |
* |
* |
5 |
* $Id$ |
* $Id$ |
6 |
* |
* |
7 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
8 |
* @author Suren Markosyan <suren@bcsweb.com> |
* @author Suren Markosyan <suren@bcsweb.com> |
9 |
* @package phpHtmlLib |
* @package phpHtmlLib |
10 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
18 |
* textarea field. It has no validation method. |
* textarea field. It has no validation method. |
19 |
* |
* |
20 |
* |
* |
21 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
22 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
23 |
* @package phpHtmlLib |
* @package phpHtmlLib |
24 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
27 |
*/ |
*/ |
28 |
class FETextArea extends FEBoxElement { |
class FETextArea extends FEBoxElement { |
29 |
|
|
30 |
|
|
31 |
|
/** |
32 |
|
* The constructor |
33 |
|
* |
34 |
|
* @param label string - text label for the element |
35 |
|
* @param bool required - is this a required element |
36 |
|
* @param int required - the rows attribute |
37 |
|
* @param int required - the cols attribute |
38 |
|
* @param int optional - element width in pixels (px), percentage (%) or elements (em) |
39 |
|
* @param int optional - element height in pixels (px), percentage (%) or elements (em) |
40 |
|
* @param int optional - the number of characters to limit the value to. |
41 |
|
*/ |
42 |
|
function FETextArea($label, $required = TRUE, $rows, $cols, $width = NULL, $height = NULL, |
43 |
|
$limit_char_count=-1 ) { |
44 |
|
$this->_limit_char_count = $limit_char_count; |
45 |
|
$this->FEBoxElement($label, $required, $width, $height); |
46 |
|
$this->set_rows( $rows ); |
47 |
|
$this->set_cols( $cols ); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
/** |
52 |
|
* This lets you limit the amount of data to |
53 |
|
* accept in the field |
54 |
|
*/ |
55 |
|
var $_limit_char_count = -1; |
56 |
|
|
57 |
/** |
/** |
58 |
* This function builds and returns the |
* This function builds and returns the |
59 |
* form element object |
* form element object |
72 |
return $tag; |
return $tag; |
73 |
} |
} |
74 |
|
|
75 |
|
|
76 |
|
/** |
77 |
|
* This method validates the data |
78 |
|
* for this Form Element. |
79 |
|
* |
80 |
|
* It validates as is_name(). |
81 |
|
* @param FormValidation object. |
82 |
|
*/ |
83 |
|
function validate(&$_FormValidation) { |
84 |
|
if ($this->_limit_char_count > 0) { |
85 |
|
$length = strlen($this->get_value()); |
86 |
|
if ($length > $this->_limit_char_count) { |
87 |
|
$_FormValidation->_error("INVALID_LENGTH_N"); |
88 |
|
$this->set_error_message( str_replace(array("XX_MAX", "XX_LENGTH"), |
89 |
|
array($this->_limit_char_count, $length), |
90 |
|
$_FormValidation->get_error_message() )); |
91 |
|
return FALSE; |
92 |
|
} |
93 |
|
} |
94 |
|
return TRUE; |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
/** |
99 |
|
* This method is used as a shortcut |
100 |
|
* to set the rows attribute |
101 |
|
* |
102 |
|
* @param int the rows attribute value |
103 |
|
*/ |
104 |
|
function set_rows( $rows ) { |
105 |
|
$this->set_attribute("rows", $rows); |
106 |
|
} |
107 |
|
|
108 |
|
/** |
109 |
|
* This method is used as a shortcut |
110 |
|
* to set the cols attribute |
111 |
|
* |
112 |
|
* @param int the cols attribute value |
113 |
|
*/ |
114 |
|
function set_cols( $cols ) { |
115 |
|
$this->set_attribute("cols", $cols); |
116 |
|
} |
117 |
|
|
118 |
} |
} |
119 |
?> |
?> |