Commit 36d9fe0b authored by Taylor Otwell's avatar Taylor Otwell

Added Form::open_secure and Form::open_secure_for_files

parent 64351b22
......@@ -15,11 +15,12 @@ class Form {
* @param string $action
* @param string $method
* @param array $attributes
* @param bool $https
* @return string
*/
public static function open($action = null, $method = 'POST', $attributes = array())
public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
{
$attributes['action'] = HTML::entities(URL::to((is_null($action)) ? Request::uri() : $action));
$attributes['action'] = HTML::entities(URL::to(((is_null($action)) ? Request::uri() : $action), $https));
// If the request method is PUT or DELETE, we'll default the request method to POST
// since the request method is being spoofed by the form.
......@@ -42,19 +43,46 @@ class Form {
return $html.PHP_EOL;
}
/**
* Open a HTML form with a HTTPS action.
*
* @param string $action
* @param string $method
* @param array $attributes
* @return string
*/
public static function open_secure($action = null, $method = 'POST', $attributes = array())
{
return static::open($action, $method, $attributes, true);
}
/**
* Open a HTML form that accepts file uploads.
*
* @param string $action
* @param string $method
* @param array $attributes
* @param bool $https
* @return string
*/
public static function open_for_files($action = null, $method = 'POST', $attributes = array())
public static function open_for_files($action = null, $method = 'POST', $attributes = array(), $https = false)
{
$attributes['enctype'] = 'multipart/form-data';
return static::open($action, $method, $attributes);
return static::open($action, $method, $attributes, $https);
}
/**
* Open a HTML form that accepts file uploads with a HTTPS action.
*
* @param string $action
* @param string $method
* @param array $attributes
* @return string
*/
public static function open_secure_for_files($action = null, $method = 'POST', $attributes = array())
{
return static::open_for_files($action, $method, $attributes, true);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment