Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
PSDI Army
yii2
Commits
305e8cbd
Commit
305e8cbd
authored
May 22, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored Html.
parent
bfb39ed8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
29 deletions
+26
-29
BaseHtml.php
framework/helpers/BaseHtml.php
+26
-29
No files found.
framework/helpers/BaseHtml.php
View file @
305e8cbd
...
@@ -744,6 +744,7 @@ class BaseHtml
...
@@ -744,6 +744,7 @@ class BaseHtml
return
static
::
listBox
(
$name
,
$selection
,
$items
,
$options
);
return
static
::
listBox
(
$name
,
$selection
,
$items
,
$options
);
}
}
$options
[
'name'
]
=
$name
;
$options
[
'name'
]
=
$name
;
unset
(
$options
[
'unselect'
]);
$selectOptions
=
static
::
renderSelectOptions
(
$selection
,
$items
,
$options
);
$selectOptions
=
static
::
renderSelectOptions
(
$selection
,
$items
,
$options
);
return
static
::
tag
(
'select'
,
"
\n
"
.
$selectOptions
.
"
\n
"
,
$options
);
return
static
::
tag
(
'select'
,
"
\n
"
.
$selectOptions
.
"
\n
"
,
$options
);
}
}
...
@@ -1367,16 +1368,11 @@ class BaseHtml
...
@@ -1367,16 +1368,11 @@ class BaseHtml
*/
*/
public
static
function
activeDropDownList
(
$model
,
$attribute
,
$items
,
$options
=
[])
public
static
function
activeDropDownList
(
$model
,
$attribute
,
$items
,
$options
=
[])
{
{
if
(
!
empty
(
$options
[
'multiple'
]))
{
if
(
empty
(
$options
[
'multiple'
]))
{
return
static
::
activeListInput
(
'dropDownList'
,
$model
,
$attribute
,
$items
,
$options
);
}
else
{
return
static
::
activeListBox
(
$model
,
$attribute
,
$items
,
$options
);
return
static
::
activeListBox
(
$model
,
$attribute
,
$items
,
$options
);
}
}
$name
=
isset
(
$options
[
'name'
])
?
$options
[
'name'
]
:
static
::
getInputName
(
$model
,
$attribute
);
$selection
=
static
::
getAttributeValue
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
static
::
getInputId
(
$model
,
$attribute
);
}
return
static
::
dropDownList
(
$name
,
$selection
,
$items
,
$options
);
}
}
/**
/**
...
@@ -1422,16 +1418,7 @@ class BaseHtml
...
@@ -1422,16 +1418,7 @@ class BaseHtml
*/
*/
public
static
function
activeListBox
(
$model
,
$attribute
,
$items
,
$options
=
[])
public
static
function
activeListBox
(
$model
,
$attribute
,
$items
,
$options
=
[])
{
{
$name
=
isset
(
$options
[
'name'
])
?
$options
[
'name'
]
:
static
::
getInputName
(
$model
,
$attribute
);
return
static
::
activeListInput
(
'listBox'
,
$model
,
$attribute
,
$items
,
$options
);
$selection
=
static
::
getAttributeValue
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'unselect'
,
$options
))
{
$options
[
'unselect'
]
=
''
;
}
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
static
::
getInputId
(
$model
,
$attribute
);
}
return
static
::
listBox
(
$name
,
$selection
,
$items
,
$options
);
}
}
/**
/**
...
@@ -1468,16 +1455,7 @@ class BaseHtml
...
@@ -1468,16 +1455,7 @@ class BaseHtml
*/
*/
public
static
function
activeCheckboxList
(
$model
,
$attribute
,
$items
,
$options
=
[])
public
static
function
activeCheckboxList
(
$model
,
$attribute
,
$items
,
$options
=
[])
{
{
$name
=
isset
(
$options
[
'name'
])
?
$options
[
'name'
]
:
static
::
getInputName
(
$model
,
$attribute
);
return
static
::
activeListInput
(
'checkboxList'
,
$model
,
$attribute
,
$items
,
$options
);
$selection
=
static
::
getAttributeValue
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'unselect'
,
$options
))
{
$options
[
'unselect'
]
=
''
;
}
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
static
::
getInputId
(
$model
,
$attribute
);
}
return
static
::
checkboxList
(
$name
,
$selection
,
$items
,
$options
);
}
}
/**
/**
...
@@ -1513,6 +1491,25 @@ class BaseHtml
...
@@ -1513,6 +1491,25 @@ class BaseHtml
*/
*/
public
static
function
activeRadioList
(
$model
,
$attribute
,
$items
,
$options
=
[])
public
static
function
activeRadioList
(
$model
,
$attribute
,
$items
,
$options
=
[])
{
{
return
static
::
activeListInput
(
'radioList'
,
$model
,
$attribute
,
$items
,
$options
);
}
/**
* Generates a list of input fields.
* This method is mainly called by [[activeListBox()]], [[activeRadioList()]] and [[activeCheckBoxList()]].
* @param string $type the input type. This can be 'listBox', 'radioList', or 'checkBoxList'.
* @param Model $model the model object
* @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
* about attribute expression.
* @param array $items the data item used to generate the input fields.
* The array keys are the labels, while the array values are the corresponding input values.
* Note that the labels will NOT be HTML-encoded, while the values will.
* @param array $options options (name => config) for the input list. The supported special options
* depend on the input type specified by `$type`.
* @return string the generated input list
*/
protected
static
function
activeListInput
(
$type
,
$model
,
$attribute
,
$items
,
$options
=
[])
{
$name
=
isset
(
$options
[
'name'
])
?
$options
[
'name'
]
:
static
::
getInputName
(
$model
,
$attribute
);
$name
=
isset
(
$options
[
'name'
])
?
$options
[
'name'
]
:
static
::
getInputName
(
$model
,
$attribute
);
$selection
=
static
::
getAttributeValue
(
$model
,
$attribute
);
$selection
=
static
::
getAttributeValue
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'unselect'
,
$options
))
{
if
(
!
array_key_exists
(
'unselect'
,
$options
))
{
...
@@ -1522,7 +1519,7 @@ class BaseHtml
...
@@ -1522,7 +1519,7 @@ class BaseHtml
$options
[
'id'
]
=
static
::
getInputId
(
$model
,
$attribute
);
$options
[
'id'
]
=
static
::
getInputId
(
$model
,
$attribute
);
}
}
return
static
::
radioList
(
$name
,
$selection
,
$items
,
$options
);
return
static
::
$type
(
$name
,
$selection
,
$items
,
$options
);
}
}
/**
/**
...
...
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