Changeset 1461
- Timestamp:
- 12/07/07 21:17:50 (9 months ago)
- Location:
- trunk/modules/forge
- Files:
-
- 3 modified
- 1 copied
-
controllers/forge_demo.php (modified) (1 diff)
-
i18n/en_US/forge.php (modified) (1 diff)
-
libraries/Forge.php (modified) (3 diffs)
-
libraries/Form_Hidden.php (copied) (copied from trunk/modules/forge/libraries/Form_Hidden.php) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/forge/controllers/forge_demo.php
r1460 r1461 19 19 // type($name)->attr(..)->attr(..); 20 20 // 21 $form->hidden('hideme')->value('hiddenz!'); 21 22 $form->input('email')->label(TRUE)->rules('required|valid_email'); 22 23 $form->input('username')->label(TRUE)->rules('required|length[5,32]'); -
trunk/modules/forge/i18n/en_US/forge.php
r1450 r1461 3 3 $lang = array 4 4 ( 5 'invalid_input' => 'Invalid input type requested: %s', 5 6 'address_unit' => 'Unit #', 6 7 'address_city' => 'City', -
trunk/modules/forge/libraries/Forge.php
r1459 r1461 28 28 return $this->inputs[$key]; 29 29 } 30 elseif (isset($this->hidden[$key])) 31 { 32 return $this->hidden[$key]; 33 } 30 34 } 31 35 32 36 public function __call($method, $args) 33 37 { 34 if ($method == 'hidden')35 {36 $this->hidden[$args[0]] = $args[1];37 return;38 }39 38 // Class name 40 39 $input = 'Form_'.ucfirst($method); 41 40 42 41 // Create the input 43 $input = new $input(empty($args) ? NULL : current($args)); 42 switch(count($args)) 43 { 44 case 1: 45 $input = new $input($args[0]); 46 break; 47 case 2: 48 $input = new $input($args[0], $args[1]); 49 break; 50 } 44 51 45 52 if ( ! ($input instanceof Form_Input)) 46 throw new Kohana_Exception('forge.invalid_input' );53 throw new Kohana_Exception('forge.invalid_input', get_class($input)); 47 54 48 55 if ($name = $input->name) 49 56 { 50 // Assign by name 51 $this->inputs[$name] = $input; 57 if ($method == 'hidden') 58 { 59 $this->hidden[$name] = $input; 60 } 61 else 62 { 63 // Assign by name 64 $this->inputs[$name] = $input; 65 } 52 66 } 53 67 else … … 79 93 80 94 $data = array(); 81 foreach( $this->inputsas $input)95 foreach(array_merge($this->hidden, $this->inputs) as $input) 82 96 { 83 97 if ($name = $input->name) … … 95 109 $form = new View($template, $this->template); 96 110 111 $hidden = array(); 112 if ( ! empty($this->hidden)) 113 { 114 foreach($this->hidden as $input) 115 { 116 $hidden[$input->name] = $input->value; 117 } 118 } 119 97 120 // Set the form open and close 98 $form->open = form::open($form->action, array('method' => 'post'), $ this->hidden);121 $form->open = form::open($form->action, array('method' => 'post'), $hidden); 99 122 $form->close = form::close(); 100 123 -
trunk/modules/forge/libraries/Form_Hidden.php
r1452 r1461 9 9 ); 10 10 11 protected $protect = array('type' );11 protected $protect = array('type', 'label'); 12 12 13 p rotected function html_element()13 public function html() 14 14 { 15 15 $data = $this->data; 16 17 unset($data['label']);18 16 19 17 return form::hidden($data);
