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
83623851
Commit
83623851
authored
Dec 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1397: support customization of the container tag for Html::checkbox() and radio()
parent
28ae92b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
BaseHtml.php
framework/yii/helpers/BaseHtml.php
+22
-6
No files found.
framework/yii/helpers/BaseHtml.php
View file @
83623851
...
@@ -551,8 +551,11 @@ class BaseHtml
...
@@ -551,8 +551,11 @@ class BaseHtml
* in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks.
* in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks.
* When this option is specified, the radio button will be enclosed by a label tag.
* When this option is specified, the radio button will be enclosed by a label tag.
* - labelOptions: array, the HTML attributes for the label tag. This is only used when the "label" option is specified.
* - labelOptions: array, the HTML attributes for the label tag. This is only used when the "label" option is specified.
* - container: array|boolean, the HTML attributes for the container tag. This is only used when the "label" option is specified.
* If it is false, no container will be rendered. If it is an array or not, a "div" container will be rendered
* around the the radio button.
*
*
* The rest of the options will be rendered as the attributes of the resulting tag. The values will
* The rest of the options will be rendered as the attributes of the resulting
radio button
tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
*
*
* @return string the generated radio button tag
* @return string the generated radio button tag
...
@@ -571,9 +574,14 @@ class BaseHtml
...
@@ -571,9 +574,14 @@ class BaseHtml
if
(
isset
(
$options
[
'label'
]))
{
if
(
isset
(
$options
[
'label'
]))
{
$label
=
$options
[
'label'
];
$label
=
$options
[
'label'
];
$labelOptions
=
isset
(
$options
[
'labelOptions'
])
?
$options
[
'labelOptions'
]
:
[];
$labelOptions
=
isset
(
$options
[
'labelOptions'
])
?
$options
[
'labelOptions'
]
:
[];
unset
(
$options
[
'label'
],
$options
[
'labelOptions'
]);
$container
=
isset
(
$options
[
'container'
])
?
$options
[
'container'
]
:
[
'class'
=>
'radio'
];
unset
(
$options
[
'label'
],
$options
[
'labelOptions'
],
$options
[
'container'
]);
$content
=
static
::
label
(
static
::
input
(
'radio'
,
$name
,
$value
,
$options
)
.
' '
.
$label
,
null
,
$labelOptions
);
$content
=
static
::
label
(
static
::
input
(
'radio'
,
$name
,
$value
,
$options
)
.
' '
.
$label
,
null
,
$labelOptions
);
return
$hidden
.
static
::
tag
(
'div'
,
$content
,
[
'class'
=>
'radio'
]);
if
(
is_array
(
$container
))
{
return
$hidden
.
static
::
tag
(
'div'
,
$content
,
$container
);
}
else
{
return
$hidden
.
$content
;
}
}
else
{
}
else
{
return
$hidden
.
static
::
input
(
'radio'
,
$name
,
$value
,
$options
);
return
$hidden
.
static
::
input
(
'radio'
,
$name
,
$value
,
$options
);
}
}
...
@@ -592,8 +600,11 @@ class BaseHtml
...
@@ -592,8 +600,11 @@ class BaseHtml
* in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks.
* in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks.
* When this option is specified, the checkbox will be enclosed by a label tag.
* When this option is specified, the checkbox will be enclosed by a label tag.
* - labelOptions: array, the HTML attributes for the label tag. This is only used when the "label" option is specified.
* - labelOptions: array, the HTML attributes for the label tag. This is only used when the "label" option is specified.
* - container: array|boolean, the HTML attributes for the container tag. This is only used when the "label" option is specified.
* If it is false, no container will be rendered. If it is an array or not, a "div" container will be rendered
* around the the radio button.
*
*
* The rest of the options will be rendered as the attributes of the resulting tag. The values will
* The rest of the options will be rendered as the attributes of the resulting
checkbox
tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
*
*
* @return string the generated checkbox tag
* @return string the generated checkbox tag
...
@@ -612,9 +623,14 @@ class BaseHtml
...
@@ -612,9 +623,14 @@ class BaseHtml
if
(
isset
(
$options
[
'label'
]))
{
if
(
isset
(
$options
[
'label'
]))
{
$label
=
$options
[
'label'
];
$label
=
$options
[
'label'
];
$labelOptions
=
isset
(
$options
[
'labelOptions'
])
?
$options
[
'labelOptions'
]
:
[];
$labelOptions
=
isset
(
$options
[
'labelOptions'
])
?
$options
[
'labelOptions'
]
:
[];
unset
(
$options
[
'label'
],
$options
[
'labelOptions'
]);
$container
=
isset
(
$options
[
'container'
])
?
$options
[
'container'
]
:
[
'class'
=>
'checkbox'
];
unset
(
$options
[
'label'
],
$options
[
'labelOptions'
],
$options
[
'container'
]);
$content
=
static
::
label
(
static
::
input
(
'checkbox'
,
$name
,
$value
,
$options
)
.
' '
.
$label
,
null
,
$labelOptions
);
$content
=
static
::
label
(
static
::
input
(
'checkbox'
,
$name
,
$value
,
$options
)
.
' '
.
$label
,
null
,
$labelOptions
);
return
$hidden
.
static
::
tag
(
'div'
,
$content
,
[
'class'
=>
'checkbox'
]);
if
(
is_array
(
$container
))
{
return
$hidden
.
static
::
tag
(
'div'
,
$content
,
$container
);
}
else
{
return
$hidden
.
$content
;
}
}
else
{
}
else
{
return
$hidden
.
static
::
input
(
'checkbox'
,
$name
,
$value
,
$options
);
return
$hidden
.
static
::
input
(
'checkbox'
,
$name
,
$value
,
$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