Changeset 1923 for trunk/modules/forge/libraries/Form_Input.php
- Timestamp:
- 02/05/2008 08:49:08 AM (11 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/forge/libraries/Form_Input.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1917 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE base input library. 4 * 5 * $Id$ 6 * 7 * @package Forge 8 * @author Kohana Team 9 * @copyright (c) 2007-2008 Kohana Team 10 * @license http://kohanaphp.com/license.html 11 */ 3 12 class Form_Input_Core { 4 13 … … 29 38 protected $error_messages = array(); 30 39 40 /** 41 * Sets the input element name. 42 */ 31 43 public function __construct($name) 32 44 { … … 34 46 } 35 47 48 /** 49 * Sets form attributes, or return rules. 50 */ 36 51 public function __call($method, $args) 37 52 { … … 70 85 } 71 86 87 /** 88 * Returns form attributes. 89 * 90 * @param string attribute name 91 * @return string 92 */ 72 93 public function __get($key) 73 94 { … … 78 99 } 79 100 101 /** 102 * Sets a form element that this element must match the value of. 103 * 104 * @chainable 105 * @param object another Forge input 106 * @return object 107 */ 80 108 public function matches($input) 81 109 { … … 88 116 } 89 117 118 /** 119 * Sets a callback method as a rule for this input. 120 * 121 * @chainable 122 * @param callback 123 * @return object 124 */ 90 125 public function callback($callback) 91 126 { … … 98 133 } 99 134 135 /** 136 * Sets or returns the input label. 137 * 138 * @chainable 139 * @param string label to set 140 * @return string|object 141 */ 100 142 public function label($val = NULL) 101 143 { … … 115 157 } 116 158 159 /** 160 * Set or return the error message. 161 * 162 * @chainable 163 * @param string error message 164 * @return strong|object 165 */ 117 166 public function message($val = NULL) 118 167 { … … 129 178 } 130 179 180 /** 181 * Runs validation and returns the element HTML. 182 * 183 * @return string 184 */ 131 185 public function html() 132 186 { … … 137 191 } 138 192 193 /** 194 * Returns the form input HTML. 195 * 196 * @return string 197 */ 139 198 protected function html_element() 140 199 { … … 147 206 } 148 207 208 /** 209 * Replace, remove, or append rules. 210 * 211 * @param array rules to change 212 * @param string action to use: replace, remove, append 213 */ 149 214 protected function add_rules( array $rules, $action) 150 215 { … … 183 248 } 184 249 250 /** 251 * Add an error to the input. 252 * 253 * @chainable 254 * @return object 255 */ 185 256 public function add_error($key, $val) 186 257 { … … 193 264 } 194 265 266 /** 267 * Set or return the error messages. 268 * 269 * @chainable 270 * @param string|array failed validation function, or an array of messages 271 * @param string error message 272 * @return object|array 273 */ 195 274 public function error_messages($func = NULL, $message = NULL) 196 275 { … … 281 360 } 282 361 362 /** 363 * Get the global input value. 364 * 365 * @return string|bool 366 */ 283 367 protected function input_value() 284 368 { … … 297 381 } 298 382 383 /** 384 * Load the value of the input, if form data is present. 385 * 386 * @return void 387 */ 299 388 protected function load_value() 300 389 { … … 315 404 } 316 405 406 /** 407 * Validate this input based on the set rules. 408 * 409 * @return bool 410 */ 317 411 public function validate() 318 412 { … … 424 518 } 425 519 520 /** 521 * Validate required. 522 */ 426 523 protected function rule_required() 427 524 { … … 432 529 } 433 530 531 /** 532 * Validate length. 533 */ 434 534 protected function rule_length($min, $max = NULL) 435 535 {
