Ejemplo n.º 1
0
 /**
  * Generates an opening HTML form tag.
  *
  * // Form will submit back to the current page using POST
  * echo Form::open();
  *
  * // Form will submit to 'search' using GET
  * echo Form::open('search', array('method' => 'get'));
  *
  * // When "file" inputs are present, you must include the "enctype"
  * echo Form::open(null, array('enctype' => 'multipart/form-data'));
  *
  * @param   string  form action, defaults to the current request URI
  * @param   array   html attributes
  * @return  string
  * @uses	HttpIO::instance
  * @uses	URL::site
  * @uses	HTML::attributes
  */
 public static function open($action = null, array $attributes = null)
 {
     if ($action === null) {
         // Use the current URI
         $action = HttpIO::current()->uri;
     }
     if (strpos($action, '://') === false) {
         // Make the URI absolute
         $action = Core::url($action);
     }
     // Add the form action to the attributes
     $attributes['action'] = $action;
     // Only accept the default character set
     $attributes['accept-charset'] = Core::$charset;
     if (!isset($attributes['method'])) {
         // Use POST method
         $attributes['method'] = 'post';
     }
     return '<form' . HTML::attributes($attributes) . '>';
 }