Example #1
0
 public static function form_for($spaces, $model, array $attributes = NULL)
 {
     if (static::$form_open === FALSE) {
         echo Form::model($model, $attributes);
         ob_start();
         if (empty($attributes['method'])) {
             $attributes['method'] = $model->loaded() ? 'PUT' : 'POST';
         }
         if (!empty($attributes['method']) && $attributes['method'] !== 'GET' && $attributes['method'] !== 'POST') {
             echo Form::hidden('_method', $attributes['method']) . "\n";
             $attributes['method'] = 'POST';
         }
         echo Form::hidden('utf8', '✓') . "\n";
         if ($attributes['method'] !== 'GET') {
             echo Form::hidden('authenticity_token', Security::token()) . "\n";
         }
         static::$form_open = TRUE;
     } else {
         echo View::adjust_indent(ob_get_clean(), $spaces, TRUE);
         echo Form::close() . "\n";
         static::$form_open = FALSE;
     }
     return static::$form_open;
 }