Changeset 1923
- Timestamp:
- 02/05/2008 08:49:08 AM (10 months ago)
- Location:
- trunk/modules/forge
- Files:
-
- 14 modified
-
controllers/forge_demo.php (modified) (1 prop)
-
i18n/en_US/forge.php (modified) (1 prop)
-
libraries/Forge.php (modified) (7 diffs, 1 prop)
-
libraries/Form_Checkbox.php (modified) (2 diffs, 1 prop)
-
libraries/Form_Checklist.php (modified) (1 diff, 1 prop)
-
libraries/Form_Dateselect.php (modified) (1 diff, 1 prop)
-
libraries/Form_Dropdown.php (modified) (1 diff, 1 prop)
-
libraries/Form_Group.php (modified) (1 diff, 1 prop)
-
libraries/Form_Hidden.php (modified) (1 diff, 1 prop)
-
libraries/Form_Input.php (modified) (18 diffs, 1 prop)
-
libraries/Form_Password.php (modified) (1 diff, 1 prop)
-
libraries/Form_Submit.php (modified) (1 diff, 1 prop)
-
libraries/Form_Textarea.php (modified) (1 diff, 1 prop)
-
libraries/Form_Upload.php (modified) (2 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/forge/controllers/forge_demo.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
-
trunk/modules/forge/i18n/en_US/forge.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
-
trunk/modules/forge/libraries/Forge.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 (FORm GEneration) 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 Forge_Core { 4 13 … … 23 32 public $newline_char = "\n"; 24 33 34 /** 35 * Form constructor. Sets the form action, title, method, and attributes. 36 * 37 * @return void 38 */ 25 39 public function __construct($action = '', $title = '', $method = NULL, $attr = array()) 26 40 { … … 42 56 } 43 57 58 /** 59 * Magic __get method. Returns the specified form element. 60 * 61 * @param string unique input name 62 * @return object 63 */ 44 64 public function __get($key) 45 65 { … … 54 74 } 55 75 76 /** 77 * Magic __call method. Creates a new form element object. 78 * 79 * @throws Kohana_Exception 80 * @param string input type 81 * @param string input name 82 * @return object 83 */ 56 84 public function __call($method, $args) 57 85 { … … 96 124 } 97 125 126 /** 127 * Set a form attribute. This method is chainable. 128 * 129 * @param string|array attribute name, or an array of attributes 130 * @param string attribute value 131 * @return object 132 */ 133 public function set_attr($key, $val = NULL) 134 { 135 if (is_array($key)) 136 { 137 // Merge the new attributes with the old ones 138 $this->attr = array_merge($this->attr, $key); 139 } 140 else 141 { 142 // Set the new attribute 143 $this->attr[$key] = $val; 144 } 145 146 return $this; 147 } 148 149 /** 150 * Validates the form by running each inputs validation rules. 151 * 152 * @return bool 153 */ 98 154 public function validate() 99 155 { … … 110 166 } 111 167 168 /** 169 * Returns the form as an array of input names and values. 170 * 171 * @return array 172 */ 112 173 public function as_array() 113 174 { … … 124 185 } 125 186 187 /** 188 * Changes the error message format. Your message formatting must 189 * contain a {message} placeholder. 190 * 191 * @throws Kohana_Exception 192 * @param string new message format 193 * @return void 194 */ 126 195 public function error_format($string = '') 127 196 { -
trunk/modules/forge/libraries/Form_Checkbox.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1594 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE checkbox 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_Checkbox_Core extends Form_Input { 4 13 … … 22 31 23 32 return parent::__get($key); 24 }25 26 public function label($val = NULL)27 {28 if ($val === NULL)29 {30 return '';31 }32 else33 {34 $this->data['label'] = ($val === TRUE) ? ucwords(inflector::humanize($this->name)) : $val;35 return $this;36 }37 33 } 38 34 -
trunk/modules/forge/libraries/Form_Checklist.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1594 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE checklist 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_Checklist_Core extends Form_Input { 4 13 -
trunk/modules/forge/libraries/Form_Dateselect.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1594 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE dateselect 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_Dateselect_Core extends Form_Input { 4 13 -
trunk/modules/forge/libraries/Form_Dropdown.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1595 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE dropdown 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_Dropdown_Core extends Form_Input { 4 13 -
trunk/modules/forge/libraries/Form_Group.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1710 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE group 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_Group_Core extends Forge { 4 13 -
trunk/modules/forge/libraries/Form_Hidden.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1522 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE hidden 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_Hidden_Core extends Form_Input { 4 13 -
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 { -
trunk/modules/forge/libraries/Form_Password.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1522 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE password 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_Password_Core extends Form_Input { 4 13 -
trunk/modules/forge/libraries/Form_Submit.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1522 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE submit 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_Submit_Core extends Form_Input { 4 13 -
trunk/modules/forge/libraries/Form_Textarea.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1522 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE textarea 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_Textarea_Core extends Form_Input { 4 13 -
trunk/modules/forge/libraries/Form_Upload.php
- Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
r1658 r1923 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * FORGE upload 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_Upload_Core extends Form_Input { 4 13 … … 42 51 } 43 52 53 /** 54 * Sets the upload directory. 55 * 56 * @param string upload directory 57 * @return void 58 */ 44 59 public function directory($dir = NULL) 45 60 {
