mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
@ -162,10 +162,10 @@ especifica directamente.
|
||||
Los métodos más genéricos son:
|
||||
|
||||
```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]) ?>
|
||||
```
|
||||
|
||||
@ -282,13 +282,13 @@ Existen dos métodos para generar etiquetas que envuelvan estilos y scripts incr
|
||||
```php
|
||||
<?= Html::style('.danger { color: #f00; }') ?>
|
||||
|
||||
// Genera
|
||||
Genera
|
||||
|
||||
<style>.danger { color: #f00; }</style>
|
||||
|
||||
<?= Html::script('alert("Hello!");', ['defer' => true]);
|
||||
|
||||
// Genera
|
||||
Genera
|
||||
|
||||
<script defer>alert("Hello!");</script>
|
||||
```
|
||||
@ -298,7 +298,7 @@ Si se quiere enlazar un estilo externo desde un archivo CSS:
|
||||
```php
|
||||
<?= Html::cssFile('@web/css/ie5.css', ['condition' => 'IE 5']) ?>
|
||||
|
||||
// genera
|
||||
genera
|
||||
|
||||
<!--[if IE 5]>
|
||||
<link href="http://example.com/css/ie5.css" />
|
||||
@ -351,7 +351,7 @@ Para generar una etiqueta de tipo imagen se puede usar el siguiente ejemplo:
|
||||
```php
|
||||
<?= Html::img('@web/images/logo.png', ['alt' => 'My logo']) ?>
|
||||
|
||||
// genera
|
||||
genera
|
||||
|
||||
<img src="http://example.com/images/logo.png" alt="My logo" />
|
||||
```
|
||||
|
||||
@ -9,6 +9,7 @@ of Html helper which provides a set of static methods for handling commonly used
|
||||
> Note: If your markup is nearly static it's better to use HTML directly. There's no need to wrap absolutely everything
|
||||
with Html helper calls.
|
||||
|
||||
|
||||
Basics <a name="basics"></a>
|
||||
----------------------------
|
||||
|
||||
@ -55,7 +56,6 @@ know about:
|
||||
When building options for HTML tag we're often starting with defaults which we need to modify. In order to add or
|
||||
remove CSS class you can use the following:
|
||||
|
||||
|
||||
```php
|
||||
$options = ['class' => 'btn btn-default'];
|
||||
|
||||
@ -115,6 +115,7 @@ dealing with them.
|
||||
|
||||
> Note: consider using [[yii\widgets\ActiveForm|ActiveForm]] in case you deal with models and need validation.
|
||||
|
||||
|
||||
### Open and close a form
|
||||
|
||||
Form could be opened with [[yii\helpers\Html::beginForm()|beginForm()]] method like the following:
|
||||
@ -134,6 +135,7 @@ Closing form tag is simple:
|
||||
<?= Html::endForm() ?>
|
||||
```
|
||||
|
||||
|
||||
### Buttons
|
||||
|
||||
In order to generate buttons you can use the following code:
|
||||
@ -154,7 +156,6 @@ There are two groups on input methods. The ones starting with `active` and calle
|
||||
with it. Active inputs are taking data from model and attribute specified while in case of regular input data is specified
|
||||
directly.
|
||||
|
||||
|
||||
The most generic methods are:
|
||||
|
||||
```php
|
||||
@ -216,7 +217,6 @@ If not, use radio list:
|
||||
|
||||
### Labels and errors
|
||||
|
||||
|
||||
Same as inputs there are two methods for generating form labels. Active that's taking data from the model and non-active
|
||||
that accepts data directly:
|
||||
|
||||
@ -278,7 +278,6 @@ Styles and scripts
|
||||
|
||||
There two methods to generate tags wrapping embedded styles and scripts:
|
||||
|
||||
|
||||
```php
|
||||
<?= Html::style('.danger { color: #f00; }') ?>
|
||||
|
||||
@ -322,6 +321,7 @@ To link JavaScript file:
|
||||
Same as with CSS first argument specifies link to the file to be included. Options could be passed as the second argument.
|
||||
In options you can specify `condition` in the same way as in options for `cssFile`.
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
@ -358,6 +358,7 @@ generates
|
||||
Aside [aliases](concept-aliases.md) the first argument can accept routes, parameters and URLs. Same way as
|
||||
[Url::to()](helper-url.md) does.
|
||||
|
||||
|
||||
Lists
|
||||
-----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user