Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
77c23c46
Commit
77c23c46
authored
Jul 06, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trim bloat from Form class.
parent
fa0e6c8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
71 deletions
+16
-71
form.php
system/form.php
+16
-71
No files found.
system/form.php
View file @
77c23c46
...
...
@@ -21,11 +21,8 @@ class Form {
{
$attributes
[
'action'
]
=
HTML
::
entities
(
URL
::
to
((
is_null
(
$action
))
?
Request
::
uri
()
:
$action
));
// -------------------------------------------------------
// If the request method is PUT or DELETE, we'll default
// the request method to POST since the reqeust method
// is being spoofed by the form.
// -------------------------------------------------------
// 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.
$attributes
[
'method'
]
=
(
$method
==
'PUT'
or
$method
==
'DELETE'
)
?
'POST'
:
$method
;
if
(
!
array_key_exists
(
'accept-charset'
,
$attributes
))
...
...
@@ -35,12 +32,8 @@ class Form {
$html
=
'<form'
.
HTML
::
attributes
(
$attributes
)
.
'>'
;
// -------------------------------------------------------
// If the method is PUT or DELETE, we'll need to spoof it
// using a hidden input field.
//
// For more information, see the Input library.
// -------------------------------------------------------
// If the request method is PUT or DELETE, create a hidden input element with the
// request method in it since HTML forms do not support these two methods.
if
(
$method
==
'PUT'
or
$method
==
'DELETE'
)
{
$html
.=
PHP_EOL
.
static
::
input
(
'hidden'
,
'REQUEST_METHOD'
,
$method
);
...
...
@@ -81,10 +74,6 @@ class Form {
*/
public
static
function
raw_token
()
{
// -------------------------------------------------------
// CSRF tokens are stored in the session, so we need to
// make sure a driver has been specified.
// -------------------------------------------------------
if
(
Config
::
get
(
'session.driver'
)
==
''
)
{
throw
new
\Exception
(
'Sessions must be enabled to retrieve a CSRF token.'
);
...
...
@@ -133,32 +122,6 @@ class Form {
return
static
::
input
(
'password'
,
$name
,
null
,
$attributes
);
}
/**
* Create a HTML email input element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
email
(
$name
,
$value
=
null
,
$attributes
=
array
())
{
return
static
::
input
(
'email'
,
$name
,
$value
,
$attributes
);
}
/**
* Create a HTML telephone input element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
telephone
(
$name
,
$value
=
null
,
$attributes
=
array
())
{
return
static
::
input
(
'tel'
,
$name
,
$value
,
$attributes
);
}
/**
* Create a HTML search input element.
*
...
...
@@ -173,42 +136,42 @@ class Form {
}
/**
* Create a HTML
URL
input element.
* Create a HTML
email
input element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
ur
l
(
$name
,
$value
=
null
,
$attributes
=
array
())
public
static
function
emai
l
(
$name
,
$value
=
null
,
$attributes
=
array
())
{
return
static
::
input
(
'
ur
l'
,
$name
,
$value
,
$attributes
);
return
static
::
input
(
'
emai
l'
,
$name
,
$value
,
$attributes
);
}
/**
* Create a HTML
color
input element.
* Create a HTML
telephone
input element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
color
(
$name
,
$value
=
null
,
$attributes
=
array
())
public
static
function
telephone
(
$name
,
$value
=
null
,
$attributes
=
array
())
{
return
static
::
input
(
'
color
'
,
$name
,
$value
,
$attributes
);
return
static
::
input
(
'
tel
'
,
$name
,
$value
,
$attributes
);
}
/**
* Create a HTML
date
input element.
* Create a HTML
URL
input element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
date
(
$name
,
$value
=
null
,
$attributes
=
array
())
public
static
function
url
(
$name
,
$value
=
null
,
$attributes
=
array
())
{
return
static
::
input
(
'
date
'
,
$name
,
$value
,
$attributes
);
return
static
::
input
(
'
url
'
,
$name
,
$value
,
$attributes
);
}
/**
...
...
@@ -224,19 +187,6 @@ class Form {
return
static
::
input
(
'number'
,
$name
,
$value
,
$attributes
);
}
/**
* Create a HTML range input element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
range
(
$name
,
$value
=
null
,
$attributes
=
array
())
{
return
static
::
input
(
'range'
,
$name
,
$value
,
$attributes
);
}
/**
* Create a HTML file input element.
*
...
...
@@ -396,25 +346,20 @@ 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
*/
private
static
function
id
(
$name
,
$attributes
)
{
// -------------------------------------------------------
// If an ID attribute was already explicitly specified
// for the element in its attributes, use that ID.
// -------------------------------------------------------
if
(
array_key_exists
(
'id'
,
$attributes
))
{
return
$attributes
[
'id'
];
}
// -------------------------------------------------------
// If a label element was created with a value matching
// the name of the form element, use the name as the ID.
// -------------------------------------------------------
if
(
in_array
(
$name
,
static
::
$labels
))
{
return
$name
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment