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
34387fc4
Commit
34387fc4
authored
Jun 14, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:taylorotwell/laravel into develop
parents
30c83f26
8161e2c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
form.php
system/form.php
+37
-0
No files found.
system/form.php
View file @
34387fc4
...
@@ -2,6 +2,13 @@
...
@@ -2,6 +2,13 @@
class
Form
{
class
Form
{
/**
* Stores labels names.
*
* @var array
*/
private
static
$labels
=
array
();
/**
/**
* Open a HTML form.
* Open a HTML form.
*
*
...
@@ -46,6 +53,16 @@ class Form {
...
@@ -46,6 +53,16 @@ class Form {
return
$html
.
PHP_EOL
;
return
$html
.
PHP_EOL
;
}
}
/**
* Close a HTML form.
*
* @return void
*/
public
static
function
close
()
{
return
'</form>'
.
PHP_EOL
;
}
/**
/**
* Generate a hidden field containing the current CSRF token.
* Generate a hidden field containing the current CSRF token.
*
*
...
@@ -71,6 +88,21 @@ class Form {
...
@@ -71,6 +88,21 @@ class Form {
return
Session
::
get
(
'csrf_token'
);
return
Session
::
get
(
'csrf_token'
);
}
}
/**
* Create a HTML label element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public
static
function
label
(
$name
,
$value
,
$attributes
=
array
())
{
static
::
$labels
[]
=
$name
;
return
'<label for="'
.
$name
.
'"'
.
HTML
::
attributes
(
$attributes
)
.
'>'
.
HTML
::
entities
(
$value
)
.
'</label>'
.
PHP_EOL
;
}
/**
/**
* Create a HTML text input element.
* Create a HTML text input element.
*
*
...
@@ -190,6 +222,8 @@ class Form {
...
@@ -190,6 +222,8 @@ class Form {
$attributes
[
'checked'
]
=
'checked'
;
$attributes
[
'checked'
]
=
'checked'
;
}
}
(
in_array
(
$name
,
static
::
$labels
))
?
$attributes
[
'id'
]
=
$name
:
null
;
return
static
::
input
(
$type
,
$name
,
$value
,
$attributes
);
return
static
::
input
(
$type
,
$name
,
$value
,
$attributes
);
}
}
...
@@ -204,6 +238,7 @@ class Form {
...
@@ -204,6 +238,7 @@ class Form {
public
static
function
textarea
(
$name
,
$value
=
''
,
$attributes
=
array
())
public
static
function
textarea
(
$name
,
$value
=
''
,
$attributes
=
array
())
{
{
$attributes
[
'name'
]
=
$name
;
$attributes
[
'name'
]
=
$name
;
(
in_array
(
$name
,
static
::
$labels
))
?
$attributes
[
'id'
]
=
$name
:
null
;
// -------------------------------------------------------
// -------------------------------------------------------
// Set the default number of rows.
// Set the default number of rows.
...
@@ -236,6 +271,7 @@ class Form {
...
@@ -236,6 +271,7 @@ class Form {
public
static
function
select
(
$name
,
$options
=
array
(),
$selected
=
null
,
$attributes
=
array
())
public
static
function
select
(
$name
,
$options
=
array
(),
$selected
=
null
,
$attributes
=
array
())
{
{
$attributes
[
'name'
]
=
$name
;
$attributes
[
'name'
]
=
$name
;
(
in_array
(
$name
,
static
::
$labels
))
?
$attributes
[
'id'
]
=
$name
:
null
;
$html_options
=
array
();
$html_options
=
array
();
...
@@ -265,6 +301,7 @@ class Form {
...
@@ -265,6 +301,7 @@ class Form {
$attributes
[
'type'
]
=
$type
;
$attributes
[
'type'
]
=
$type
;
$attributes
[
'name'
]
=
$name
;
$attributes
[
'name'
]
=
$name
;
$attributes
[
'value'
]
=
$value
;
$attributes
[
'value'
]
=
$value
;
(
in_array
(
$name
,
static
::
$labels
))
?
$attributes
[
'id'
]
=
$name
:
null
;
return
'<input'
.
HTML
::
attributes
(
$attributes
)
.
' />'
.
PHP_EOL
;
return
'<input'
.
HTML
::
attributes
(
$attributes
)
.
' />'
.
PHP_EOL
;
}
}
...
...
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