Show
Ignore:
Timestamp:
01/01/2008 06:35:57 PM (12 months ago)
Author:
Shadowhand
Message:

Couple of quick changes:

  • Added comma to the default allowed URI characters
  • Updated forge_demo with an upload demo (not functional)
  • Started outlining some more rules in Form_Upload
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/forge/controllers/forge_demo.php

    r1522 r1653  
    77                $profiler = new Profiler; 
    88 
    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                ); 
    1416 
    1517                $form = new Forge(NULL, 'New User'); 
     
    3840        } 
    3941 
    40         public function edit_user($id = FALSE) 
     42        public function upload() 
    4143        { 
    4244                $profiler = new Profiler; 
    43                 $cache = new Cache; 
    4445 
    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'); 
    4749 
    48                 if (empty($_POST)) 
     50                if ($form->validate()) 
    4951                { 
    50                         // Attempt to get the HTML from cache 
    51                         if ($form = $cache->get($cache_id)) 
    52                         { 
    53                                 echo $form; 
    54                                 return; 
    55                         } 
     52 
    5653                } 
    5754 
    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(); 
    7656        } 
    7757