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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
8ac79a35
Commit
8ac79a35
authored
Apr 11, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support hiding error and label tags via error(false) and label(false).
parent
b5f351b6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
ActiveField.php
framework/widgets/ActiveField.php
+14
-2
No files found.
framework/widgets/ActiveField.php
View file @
8ac79a35
...
@@ -226,7 +226,8 @@ class ActiveField extends Component
...
@@ -226,7 +226,8 @@ class ActiveField extends Component
/**
/**
* Generates a label tag for [[attribute]].
* Generates a label tag for [[attribute]].
* @param string $label the label to use. If null, it will be generated via [[Model::getAttributeLabel()]].
* @param string|boolean $label the label to use. If null, the label will be generated via [[Model::getAttributeLabel()]].
* If false, the generated field will not contain the label part.
* Note that this will NOT be [[Html::encode()|encoded]].
* Note that this will NOT be [[Html::encode()|encoded]].
* @param array $options the tag options in terms of name-value pairs. It will be merged with [[labelOptions]].
* @param array $options the tag options in terms of name-value pairs. It will be merged with [[labelOptions]].
* The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded
* The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded
...
@@ -235,6 +236,11 @@ class ActiveField extends Component
...
@@ -235,6 +236,11 @@ class ActiveField extends Component
*/
*/
public
function
label
(
$label
=
null
,
$options
=
[])
public
function
label
(
$label
=
null
,
$options
=
[])
{
{
if
(
$label
===
false
)
{
$this
->
parts
[
'{label}'
]
=
''
;
return
$this
;
}
$options
=
array_merge
(
$this
->
labelOptions
,
$options
);
$options
=
array_merge
(
$this
->
labelOptions
,
$options
);
if
(
$label
!==
null
)
{
if
(
$label
!==
null
)
{
$options
[
'label'
]
=
$label
;
$options
[
'label'
]
=
$label
;
...
@@ -247,7 +253,7 @@ class ActiveField extends Component
...
@@ -247,7 +253,7 @@ class ActiveField extends Component
/**
/**
* Generates a tag that contains the first validation error of [[attribute]].
* Generates a tag that contains the first validation error of [[attribute]].
* Note that even if there is no validation error, this method will still return an empty error tag.
* Note that even if there is no validation error, this method will still return an empty error tag.
* @param array $options the tag options in terms of name-value pairs. It will be merged with [[errorOptions]].
* @param array
|boolean
$options the tag options in terms of name-value pairs. It will be merged with [[errorOptions]].
* The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded
* The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded
* using [[Html::encode()]]. If a value is null, the corresponding attribute will not be rendered.
* using [[Html::encode()]]. If a value is null, the corresponding attribute will not be rendered.
*
*
...
@@ -255,10 +261,16 @@ class ActiveField extends Component
...
@@ -255,10 +261,16 @@ class ActiveField extends Component
*
*
* - tag: this specifies the tag name. If not set, "div" will be used.
* - tag: this specifies the tag name. If not set, "div" will be used.
*
*
* If this parameter is false, no error tag will be rendered.
*
* @return static the field object itself
* @return static the field object itself
*/
*/
public
function
error
(
$options
=
[])
public
function
error
(
$options
=
[])
{
{
if
(
$options
===
false
)
{
$this
->
parts
[
'{error}'
]
=
''
;
return
$this
;
}
$options
=
array_merge
(
$this
->
errorOptions
,
$options
);
$options
=
array_merge
(
$this
->
errorOptions
,
$options
);
$this
->
parts
[
'{error}'
]
=
Html
::
error
(
$this
->
model
,
$this
->
attribute
,
$options
);
$this
->
parts
[
'{error}'
]
=
Html
::
error
(
$this
->
model
,
$this
->
attribute
,
$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