Changeset 1923 for trunk/modules/forge/libraries/Forge.php
- Timestamp:
- 02/05/2008 08:49:08 AM (11 months ago)
- Files:
-
- 1 modified
-
trunk/modules/forge/libraries/Forge.php (modified) (7 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
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 {
