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
11c14a20
Commit
11c14a20
authored
Jun 19, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified button signature.
parent
9a5ca995
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
38 deletions
+33
-38
login.php
apps/advanced/backend/views/site/login.php
+1
-1
contact.php
apps/advanced/frontend/views/site/contact.php
+1
-1
login.php
apps/advanced/frontend/views/site/login.php
+1
-1
contact.php
apps/basic/views/site/contact.php
+1
-1
login.php
apps/basic/views/site/login.php
+1
-1
Html.php
framework/yii/helpers/base/Html.php
+20
-25
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+8
-8
No files found.
apps/advanced/backend/views/site/login.php
View file @
11c14a20
...
...
@@ -22,6 +22,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?php
echo
$form
->
field
(
'password'
)
->
passwordInput
();
?>
<?php
echo
$form
->
field
(
'rememberMe'
)
->
checkbox
();
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Login'
,
null
,
null
,
array
(
'class'
=>
'btn btn-primary'
));
?>
<?php
echo
Html
::
submitButton
(
'Login'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
apps/advanced/frontend/views/site/contact.php
View file @
11c14a20
...
...
@@ -36,6 +36,6 @@ $this->params['breadcrumbs'][] = $this->title;
'options'
=>
array
(
'class'
=>
'input-medium'
),
));
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Submit'
,
null
,
null
,
array
(
'class'
=>
'btn btn-primary'
));
?>
<?php
echo
Html
::
submitButton
(
'Submit'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
apps/advanced/frontend/views/site/login.php
View file @
11c14a20
...
...
@@ -22,6 +22,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?php
echo
$form
->
field
(
'password'
)
->
passwordInput
();
?>
<?php
echo
$form
->
field
(
'rememberMe'
)
->
checkbox
();
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Login'
,
null
,
null
,
array
(
'class'
=>
'btn btn-primary'
));
?>
<?php
echo
Html
::
submitButton
(
'Login'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
apps/basic/views/site/contact.php
View file @
11c14a20
...
...
@@ -36,6 +36,6 @@ $this->params['breadcrumbs'][] = $this->title;
'options'
=>
array
(
'class'
=>
'input-medium'
),
));
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Submit'
,
null
,
null
,
array
(
'class'
=>
'btn btn-primary'
));
?>
<?php
echo
Html
::
submitButton
(
'Submit'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
apps/basic/views/site/login.php
View file @
11c14a20
...
...
@@ -22,6 +22,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?php
echo
$form
->
field
(
'password'
)
->
passwordInput
();
?>
<?php
echo
$form
->
field
(
'rememberMe'
)
->
checkbox
();
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Login'
,
null
,
null
,
array
(
'class'
=>
'btn btn-primary'
));
?>
<?php
echo
Html
::
submitButton
(
'Login'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
framework/yii/helpers/base/Html.php
View file @
11c14a20
...
...
@@ -421,18 +421,14 @@ class Html
* @param string $content the content enclosed within the button tag. It will NOT be HTML-encoded.
* Therefore you can pass in HTML code such as an image tag. If this is is coming from end users,
* you should consider [[encode()]] it to prevent XSS attacks.
* @param string $name the name attribute. If it is null, the name attribute will not be generated.
* @param string $value the value attribute. If it is null, the value attribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* If the options does not contain "type", a "type" attribute with value "button" will be rendered.
* @return string the generated button tag
*/
public
static
function
button
(
$content
=
'Button'
,
$
name
=
null
,
$value
=
null
,
$
options
=
array
())
public
static
function
button
(
$content
=
'Button'
,
$options
=
array
())
{
$options
[
'name'
]
=
$name
;
$options
[
'value'
]
=
$value
;
if
(
!
isset
(
$options
[
'type'
]))
{
$options
[
'type'
]
=
'button'
;
}
...
...
@@ -444,17 +440,15 @@ class Html
* @param string $content the content enclosed within the button tag. It will NOT be HTML-encoded.
* Therefore you can pass in HTML code such as an image tag. If this is is coming from end users,
* you should consider [[encode()]] it to prevent XSS attacks.
* @param string $name the name attribute. If it is null, the name attribute will not be generated.
* @param string $value the value attribute. If it is null, the value attribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated submit button tag
*/
public
static
function
submitButton
(
$content
=
'Submit'
,
$
name
=
null
,
$value
=
null
,
$
options
=
array
())
public
static
function
submitButton
(
$content
=
'Submit'
,
$options
=
array
())
{
$options
[
'type'
]
=
'submit'
;
return
static
::
button
(
$content
,
$
name
,
$value
,
$
options
);
return
static
::
button
(
$content
,
$options
);
}
/**
...
...
@@ -462,17 +456,15 @@ class Html
* @param string $content the content enclosed within the button tag. It will NOT be HTML-encoded.
* Therefore you can pass in HTML code such as an image tag. If this is is coming from end users,
* you should consider [[encode()]] it to prevent XSS attacks.
* @param string $name the name attribute. If it is null, the name attribute will not be generated.
* @param string $value the value attribute. If it is null, the value attribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated reset button tag
*/
public
static
function
resetButton
(
$content
=
'Reset'
,
$
name
=
null
,
$value
=
null
,
$
options
=
array
())
public
static
function
resetButton
(
$content
=
'Reset'
,
$options
=
array
())
{
$options
[
'type'
]
=
'reset'
;
return
static
::
button
(
$content
,
$
name
,
$value
,
$
options
);
return
static
::
button
(
$content
,
$options
);
}
/**
...
...
@@ -495,43 +487,46 @@ class Html
/**
* Generates an input button.
* @param string $name the name attribute.
* @param string $value the value attribute. If it is null, the value attribute will not be generated.
* @param string $label the value attribute. If it is null, the value attribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated button tag
*/
public
static
function
buttonInput
(
$
name
,
$value
=
'Button'
,
$options
=
array
())
public
static
function
buttonInput
(
$
label
=
'Button'
,
$options
=
array
())
{
return
static
::
input
(
'button'
,
$name
,
$value
,
$options
);
$options
[
'type'
]
=
'button'
;
$options
[
'value'
]
=
$label
;
return
static
::
tag
(
'input'
,
null
,
$options
);
}
/**
* Generates a submit input button.
* @param string $name the name attribute. If it is null, the name attribute will not be generated.
* @param string $value the value attribute. If it is null, the value attribute will not be generated.
* @param string $label the value attribute. If it is null, the value attribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated button tag
*/
public
static
function
submitInput
(
$
name
=
null
,
$value
=
'Submit'
,
$options
=
array
())
public
static
function
submitInput
(
$
label
=
'Submit'
,
$options
=
array
())
{
return
static
::
input
(
'submit'
,
$name
,
$value
,
$options
);
$options
[
'type'
]
=
'submit'
;
$options
[
'value'
]
=
$label
;
return
static
::
tag
(
'input'
,
null
,
$options
);
}
/**
* Generates a reset input button.
* @param string $name the name attribute. If it is null, the name attribute will not be generated.
* @param string $value the value attribute. If it is null, the value attribute will not be generated.
* @param string $label the value attribute. If it is null, the value attribute will not be generated.
* @param array $options the attributes of the button tag. The values will be HTML-encoded using [[encode()]].
* Attributes whose value is null will be ignored and not put in the tag returned.
* @return string the generated button tag
*/
public
static
function
resetInput
(
$
name
=
null
,
$value
=
'Reset'
,
$options
=
array
())
public
static
function
resetInput
(
$
label
=
'Reset'
,
$options
=
array
())
{
return
static
::
input
(
'reset'
,
$name
,
$value
,
$options
);
$options
[
'type'
]
=
'reset'
;
$options
[
'value'
]
=
$label
;
return
static
::
tag
(
'input'
,
null
,
$options
);
}
/**
...
...
tests/unit/framework/helpers/HtmlTest.php
View file @
11c14a20
...
...
@@ -154,20 +154,20 @@ class HtmlTest extends TestCase
public
function
testButton
()
{
$this
->
assertEquals
(
'<button type="button">Button</button>'
,
Html
::
button
());
$this
->
assertEquals
(
'<button type="button" name="test" value="value">content<></button>'
,
Html
::
button
(
'content<>'
,
'test'
,
'value'
));
$this
->
assertEquals
(
'<button type="submit" class="t" name="test" value="value">content<></button>'
,
Html
::
button
(
'content<>'
,
'test'
,
'value'
,
array
(
'type'
=>
'submit
'
,
'class'
=>
"t"
)));
$this
->
assertEquals
(
'<button type="button" name="test" value="value">content<></button>'
,
Html
::
button
(
'content<>'
,
array
(
'name'
=>
'test'
,
'value'
=>
'value'
)
));
$this
->
assertEquals
(
'<button type="submit" class="t" name="test" value="value">content<></button>'
,
Html
::
button
(
'content<>'
,
array
(
'type'
=>
'submit'
,
'name'
=>
'test'
,
'value'
=>
'value
'
,
'class'
=>
"t"
)));
}
public
function
testSubmitButton
()
{
$this
->
assertEquals
(
'<button type="submit">Submit</button>'
,
Html
::
submitButton
());
$this
->
assertEquals
(
'<button type="submit" class="t" name="test" value="value">content<></button>'
,
Html
::
submitButton
(
'content<>'
,
'test'
,
'value'
,
array
(
'class'
=>
't'
)));
$this
->
assertEquals
(
'<button type="submit" class="t" name="test" value="value">content<></button>'
,
Html
::
submitButton
(
'content<>'
,
array
(
'name'
=>
'test'
,
'value'
=>
'value'
,
'class'
=>
't'
)));
}
public
function
testResetButton
()
{
$this
->
assertEquals
(
'<button type="reset">Reset</button>'
,
Html
::
resetButton
());
$this
->
assertEquals
(
'<button type="reset" class="t" name="test" value="value">content<></button>'
,
Html
::
resetButton
(
'content<>'
,
'test'
,
'value'
,
array
(
'class'
=>
't'
)));
$this
->
assertEquals
(
'<button type="reset" class="t" name="test" value="value">content<></button>'
,
Html
::
resetButton
(
'content<>'
,
array
(
'name'
=>
'test'
,
'value'
=>
'value'
,
'class'
=>
't'
)));
}
public
function
testInput
()
...
...
@@ -178,20 +178,20 @@ class HtmlTest extends TestCase
public
function
testButtonInput
()
{
$this
->
assertEquals
(
'<input type="button"
name="test" value="Button" />'
,
Html
::
buttonInput
(
'test'
));
$this
->
assertEquals
(
'<input type="button" class="a" name="test" value="text" />'
,
Html
::
buttonInput
(
'te
st'
,
'text'
,
array
(
'class'
=>
'a'
)));
$this
->
assertEquals
(
'<input type="button"
value="Button" />'
,
Html
::
buttonInput
(
));
$this
->
assertEquals
(
'<input type="button" class="a" name="test" value="text" />'
,
Html
::
buttonInput
(
'te
xt'
,
array
(
'name'
=>
'test'
,
'class'
=>
'a'
)));
}
public
function
testSubmitInput
()
{
$this
->
assertEquals
(
'<input type="submit" value="Submit" />'
,
Html
::
submitInput
());
$this
->
assertEquals
(
'<input type="submit" class="a" name="test" value="text" />'
,
Html
::
submitInput
(
'te
st'
,
'text'
,
array
(
'class'
=>
'a'
)));
$this
->
assertEquals
(
'<input type="submit" class="a" name="test" value="text" />'
,
Html
::
submitInput
(
'te
xt'
,
array
(
'name'
=>
'test'
,
'class'
=>
'a'
)));
}
public
function
testResetInput
()
{
$this
->
assertEquals
(
'<input type="reset" value="Reset" />'
,
Html
::
resetInput
());
$this
->
assertEquals
(
'<input type="reset" class="a" name="test" value="text" />'
,
Html
::
resetInput
(
'te
st'
,
'text'
,
array
(
'class'
=>
'a'
)));
$this
->
assertEquals
(
'<input type="reset" class="a" name="test" value="text" />'
,
Html
::
resetInput
(
'te
xt'
,
array
(
'name'
=>
'test'
,
'class'
=>
'a'
)));
}
public
function
testTextInput
()
...
...
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