merged skunkworks into develop.
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
<?php namespace Laravel;
|
||||
|
||||
use Laravel\Session\Payload as Session;
|
||||
|
||||
class Form {
|
||||
|
||||
/**
|
||||
* All of the label names that have been created.
|
||||
*
|
||||
* These names are stored so that input elements can automatically be assigned
|
||||
* an ID based on the corresponding label name.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $labels = array();
|
||||
@@ -17,12 +12,6 @@ class Form {
|
||||
/**
|
||||
* Open a HTML form.
|
||||
*
|
||||
* If PUT or DELETE is specified as the form method, a hidden input field will be generated
|
||||
* containing the request method. PUT and DELETE are not supported by HTML forms, so the
|
||||
* hidden field will allow us to "spoof" PUT and DELETE requests.
|
||||
*
|
||||
* Unless specified, the "accept-charset" attribute will be set to the application encoding.
|
||||
*
|
||||
* <code>
|
||||
* // Open a "POST" form to the current request URI
|
||||
* echo Form::open();
|
||||
@@ -51,6 +40,9 @@ class Form {
|
||||
|
||||
$attributes['action'] = static::action($action, $https);
|
||||
|
||||
// If a character encoding has not been specified in the attributes, we will
|
||||
// use the default encoding as specified in the application configuration
|
||||
// file for the "accept-charset" attribute.
|
||||
if ( ! array_key_exists('accept-charset', $attributes))
|
||||
{
|
||||
$attributes['accept-charset'] = Config::get('application.encoding');
|
||||
@@ -58,6 +50,10 @@ class Form {
|
||||
|
||||
$append = '';
|
||||
|
||||
// Since PUT and DELETE methods are not actually supported by HTML forms,
|
||||
// we'll create a hidden input element that contains the request method
|
||||
// and set the actual request method to POST. Laravel will look for the
|
||||
// hidden element to determine the request method.
|
||||
if ($method == 'PUT' or $method == 'DELETE')
|
||||
{
|
||||
$append = static::hidden(Request::spoofer, $method);
|
||||
@@ -69,9 +65,6 @@ class Form {
|
||||
/**
|
||||
* Determine the appropriate request method to use for a form.
|
||||
*
|
||||
* Since PUT and DELETE requests are spoofed using POST requests, we will substitute
|
||||
* POST for any PUT or DELETE methods. Otherwise, the specified method will be used.
|
||||
*
|
||||
* @param string $method
|
||||
* @return string
|
||||
*/
|
||||
@@ -155,7 +148,7 @@ class Form {
|
||||
*/
|
||||
public static function token()
|
||||
{
|
||||
return static::input('hidden', Session::csrf_token, IoC::core('session')->token());
|
||||
return static::input('hidden', Session::csrf_token, Session::token());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,9 +178,6 @@ class Form {
|
||||
/**
|
||||
* Create a HTML input element.
|
||||
*
|
||||
* If an ID attribute is not specified and a label has been generated matching the input
|
||||
* element name, the label name will be used as the element ID.
|
||||
*
|
||||
* <code>
|
||||
* // Create a "text" input element named "email"
|
||||
* echo Form::input('text', 'email');
|
||||
@@ -490,8 +480,6 @@ class Form {
|
||||
/**
|
||||
* Create a HTML image input element.
|
||||
*
|
||||
* The URL::to_asset method will be called on the given URL.
|
||||
*
|
||||
* <code>
|
||||
* // Create an image input element
|
||||
* echo Form::image('img/submit.png');
|
||||
@@ -524,15 +512,16 @@ class Form {
|
||||
/**
|
||||
* Determine the ID attribute for a form element.
|
||||
*
|
||||
* An explicitly specified ID in the attributes takes first precedence, then
|
||||
* the label names will be checked for a label matching the element name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
protected static function id($name, $attributes)
|
||||
{
|
||||
// If an ID has been explicitly specified in the attributes, we will
|
||||
// use that ID. Otherwise, we will look for an ID in the array of
|
||||
// label names as this makes it convenient to give input elements
|
||||
// the same ID as their corresponding labels.
|
||||
if (array_key_exists('id', $attributes))
|
||||
{
|
||||
return $attributes['id'];
|
||||
|
||||
Reference in New Issue
Block a user