Changeset 1653 for trunk/modules/forge/controllers/forge_demo.php
- Timestamp:
- 01/01/2008 06:35:57 PM (12 months ago)
- Files:
-
- 1 modified
-
trunk/modules/forge/controllers/forge_demo.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/forge/controllers/forge_demo.php
r1522 r1653 7 7 $profiler = new Profiler; 8 8 9 $foods = array( 10 'taco' => FALSE, 11 'burger' => FALSE, 12 'spaghetti (checked)' => TRUE, 13 'cookies (checked)' => TRUE); 9 $foods = array 10 ( 11 'tacos' => array('tacos', FALSE), 12 'burgers' => array('burgers', FALSE), 13 'spaghetti' => array('spaghetti (checked)', TRUE), 14 'cookies' => array('cookies (checked)', TRUE), 15 ); 14 16 15 17 $form = new Forge(NULL, 'New User'); … … 38 40 } 39 41 40 public function edit_user($id = FALSE)42 public function upload() 41 43 { 42 44 $profiler = new Profiler; 43 $cache = new Cache;44 45 45 // Cache id for the current empty editing form 46 $cache_id = 'form--'.url::current(); 46 $form = new Forge; 47 $form->upload('file')->label(TRUE)->rules('allow[jpg,png,gif]|size[2M]'); 48 $form->submit('Upload'); 47 49 48 if ( empty($_POST))50 if ($form->validate()) 49 51 { 50 // Attempt to get the HTML from cache 51 if ($form = $cache->get($cache_id)) 52 { 53 echo $form; 54 return; 55 } 52 56 53 } 57 54 58 // Create a new user editing form 59 $form = new User_Edit_Model(NULL, 'Edit User', $id); 60 61 if ($form->save()) 62 { 63 // Cache information is no longer valid 64 $cache->del($cache_id); 65 66 echo Kohana::debug('user edited!', $form->as_array()); 67 } 68 69 if (empty($_POST)) 70 { 71 // Cache the form HTML 72 $cache->set($cache_id, $form = $form->html()); 73 } 74 75 echo $form; 55 echo $form->html(); 76 56 } 77 57
