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
a1612f5d
Commit
a1612f5d
authored
Nov 29, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1362: added itemOptions to Html::radioList and checkboxList.
parent
8307075f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
BaseHtml.php
framework/yii/helpers/BaseHtml.php
+10
-6
No files found.
framework/yii/helpers/BaseHtml.php
View file @
a1612f5d
...
@@ -739,6 +739,7 @@ class BaseHtml
...
@@ -739,6 +739,7 @@ class BaseHtml
* - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
* - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
* This option is ignored if `item` option is set.
* This option is ignored if `item` option is set.
* - separator: string, the HTML code that separates items.
* - separator: string, the HTML code that separates items.
* - itemOptions: array, the options for generating the radio button tag using [[checkbox()]].
* - item: callable, a callback that can be used to customize the generation of the HTML code
* - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callback must be:
* corresponding to a single item in $items. The signature of this callback must be:
*
*
...
@@ -758,6 +759,7 @@ class BaseHtml
...
@@ -758,6 +759,7 @@ class BaseHtml
}
}
$formatter
=
isset
(
$options
[
'item'
])
?
$options
[
'item'
]
:
null
;
$formatter
=
isset
(
$options
[
'item'
])
?
$options
[
'item'
]
:
null
;
$itemOptions
=
isset
(
$options
[
'itemOptions'
])
?
$options
[
'itemOptions'
]
:
[];
$encode
=
!
isset
(
$options
[
'encode'
])
||
$options
[
'encode'
];
$encode
=
!
isset
(
$options
[
'encode'
])
||
$options
[
'encode'
];
$lines
=
[];
$lines
=
[];
$index
=
0
;
$index
=
0
;
...
@@ -768,10 +770,10 @@ class BaseHtml
...
@@ -768,10 +770,10 @@ class BaseHtml
if
(
$formatter
!==
null
)
{
if
(
$formatter
!==
null
)
{
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
}
else
{
}
else
{
$lines
[]
=
static
::
checkbox
(
$name
,
$checked
,
[
$lines
[]
=
static
::
checkbox
(
$name
,
$checked
,
array_merge
(
$itemOptions
,
[
'value'
=>
$value
,
'value'
=>
$value
,
'label'
=>
$encode
?
static
::
encode
(
$label
)
:
$label
,
'label'
=>
$encode
?
static
::
encode
(
$label
)
:
$label
,
]);
])
)
;
}
}
$index
++
;
$index
++
;
}
}
...
@@ -786,7 +788,7 @@ class BaseHtml
...
@@ -786,7 +788,7 @@ class BaseHtml
$separator
=
isset
(
$options
[
'separator'
])
?
$options
[
'separator'
]
:
"
\n
"
;
$separator
=
isset
(
$options
[
'separator'
])
?
$options
[
'separator'
]
:
"
\n
"
;
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'div'
;
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'div'
;
unset
(
$options
[
'tag'
],
$options
[
'unselect'
],
$options
[
'encode'
],
$options
[
'separator'
],
$options
[
'item'
]);
unset
(
$options
[
'tag'
],
$options
[
'unselect'
],
$options
[
'encode'
],
$options
[
'separator'
],
$options
[
'item'
]
,
$options
[
'itemOptions'
]
);
return
$hidden
.
static
::
tag
(
$tag
,
implode
(
$separator
,
$lines
),
$options
);
return
$hidden
.
static
::
tag
(
$tag
,
implode
(
$separator
,
$lines
),
$options
);
}
}
...
@@ -805,6 +807,7 @@ class BaseHtml
...
@@ -805,6 +807,7 @@ class BaseHtml
* - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
* - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
* This option is ignored if `item` option is set.
* This option is ignored if `item` option is set.
* - separator: string, the HTML code that separates items.
* - separator: string, the HTML code that separates items.
* - itemOptions: array, the options for generating the radio button tag using [[radio()]].
* - item: callable, a callback that can be used to customize the generation of the HTML code
* - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callback must be:
* corresponding to a single item in $items. The signature of this callback must be:
*
*
...
@@ -821,6 +824,7 @@ class BaseHtml
...
@@ -821,6 +824,7 @@ class BaseHtml
{
{
$encode
=
!
isset
(
$options
[
'encode'
])
||
$options
[
'encode'
];
$encode
=
!
isset
(
$options
[
'encode'
])
||
$options
[
'encode'
];
$formatter
=
isset
(
$options
[
'item'
])
?
$options
[
'item'
]
:
null
;
$formatter
=
isset
(
$options
[
'item'
])
?
$options
[
'item'
]
:
null
;
$itemOptions
=
isset
(
$options
[
'itemOptions'
])
?
$options
[
'itemOptions'
]
:
[];
$lines
=
[];
$lines
=
[];
$index
=
0
;
$index
=
0
;
foreach
(
$items
as
$value
=>
$label
)
{
foreach
(
$items
as
$value
=>
$label
)
{
...
@@ -830,10 +834,10 @@ class BaseHtml
...
@@ -830,10 +834,10 @@ class BaseHtml
if
(
$formatter
!==
null
)
{
if
(
$formatter
!==
null
)
{
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
}
else
{
}
else
{
$lines
[]
=
static
::
radio
(
$name
,
$checked
,
[
$lines
[]
=
static
::
radio
(
$name
,
$checked
,
array_merge
(
$itemOptions
,
[
'value'
=>
$value
,
'value'
=>
$value
,
'label'
=>
$encode
?
static
::
encode
(
$label
)
:
$label
,
'label'
=>
$encode
?
static
::
encode
(
$label
)
:
$label
,
]);
])
)
;
}
}
$index
++
;
$index
++
;
}
}
...
@@ -847,7 +851,7 @@ class BaseHtml
...
@@ -847,7 +851,7 @@ class BaseHtml
}
}
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'div'
;
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'div'
;
unset
(
$options
[
'tag'
],
$options
[
'unselect'
],
$options
[
'encode'
],
$options
[
'separator'
],
$options
[
'item'
]);
unset
(
$options
[
'tag'
],
$options
[
'unselect'
],
$options
[
'encode'
],
$options
[
'separator'
],
$options
[
'item'
]
,
$options
[
'itemOptions'
]
);
return
$hidden
.
static
::
tag
(
$tag
,
implode
(
$separator
,
$lines
),
$options
);
return
$hidden
.
static
::
tag
(
$tag
,
implode
(
$separator
,
$lines
),
$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