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
2ca4f999
Commit
2ca4f999
authored
Dec 18, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Minor fixes for helper-html.md [skip ci]"
parent
0830b2fe
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
helper-html.md
docs/guide/helper-html.md
+12
-6
No files found.
docs/guide/helper-html.md
View file @
2ca4f999
...
...
@@ -88,6 +88,7 @@ could be converted there and forth by using [[yii\helpers\Html::cssStyleFromArra
[
[yii\helpers\Html::cssStyleToArray()|cssStyleToArray()
]
]. The
[
[yii\helpers\Html::removeCssStyle()|removeCssStyle()
]
]
method accepts an array of properties to remove. If it's going to be a single property it could be specified as string.
Encoding and decoding content <a name="encoding-and-decoding-content"></a>
--------------------------------------------------------------------------
...
...
@@ -105,6 +106,7 @@ echo $userName;
$decodedUserName
=
Html
::
decode
(
$userName
);
```
Forms
-----
...
...
@@ -156,10 +158,10 @@ directly.
The most generic methods are:
```
php
//
type, input name, input value, options
type, input name, input value, options
<?=
Html
::
input
(
'text'
,
'username'
,
$user
->
name
,
[
'class'
=>
$username
])
?>
//
type, model, model attribute name, options
type, model, model attribute name, options
<?=
Html
::
activeInput
(
'text'
,
$user
,
'name'
,
[
'class'
=>
$username
])
?>
```
...
...
@@ -211,6 +213,7 @@ If not, use radio list:
<?=
Html
::
activeRadioList
(
$user
,
'role'
,
ArrayHelper
::
map
(
$roleModels
,
'id'
,
'name'
))
?>
```
### Labels and errors
...
...
@@ -234,6 +237,7 @@ To display individual error:
<?=
Html
::
error
(
$post
,
'title'
,
[
'class'
=>
'error'
])
?>
```
### Names and values
There are methods to get names, ids and values for input fields based on the model. These are mainly used internally
...
...
@@ -268,6 +272,7 @@ In order to get attribute name without suffixes or prefixes one can use the foll
echo
Html
::
getAttributeName
(
'dates[0]'
);
```
Styles and scripts
------------------
...
...
@@ -277,14 +282,14 @@ There two methods to generate tags wrapping embedded styles and scripts:
```php
<?= Html::style('.danger { color: #f00; }') ?>
//
Gives you
Gives you
<style>.danger { color: #f00; }</style>
<?= Html::script('alert("Hello!");', ['defer' => true]);
//
Gives you
Gives you
<script defer>alert("Hello!");</script>
```
...
...
@@ -294,7 +299,7 @@ If you want to link external style from CSS file:
```
php
<?=
Html
::
cssFile
(
'@web/css/ie5.css'
,
[
'condition'
=>
'IE 5'
])
?>
//
generates
generates
<!--[if IE 5]>
<link href="http://example.com/css/ie5.css" />
...
...
@@ -336,6 +341,7 @@ In you need to generate `mailto` link you can use the following code:
<?=
Html
::
mailto
(
'Contact us'
,
'admin@example.com'
)
?>
```
Images
------
...
...
@@ -344,7 +350,7 @@ In order to generate image tag use the following:
```
php
<?=
Html
::
img
(
'@web/images/logo.png'
,
[
'alt'
=>
'My logo'
])
?>
//
generates
generates
<img
src=
"http://example.com/images/logo.png"
alt=
"My logo"
/>
```
...
...
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