Skip to content

Commit

Permalink
Lang attribute for HTML tags and inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-wdmg committed Feb 13, 2021
1 parent 73095bc commit a3cd30c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

## 1.2.*
* Lang attribute for HTML tags and inputs

## 1.2.5 (2020-12-29)
* RBAC implementation

Expand Down
2 changes: 1 addition & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function normalizePagesRoute($routes)
/**
* {@inheritdoc}
*/
public function dashboardNavItems($createLink = false)
public function dashboardNavItems($options = false)
{
$items = [
'label' => $this->name,
Expand Down
4 changes: 2 additions & 2 deletions migrations/m190725_005152_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function safeUp()
'route' => $this->string(255)->null(),
'layout' => $this->string(64)->null(),
'created_at' => $this->dateTime()->defaultExpression('CURRENT_TIMESTAMP'),
'created_by' => $this->integer(11)->notNull()->defaultValue(0),
'created_by' => $this->integer(11)->null(),
'updated_at' => $this->datetime()->defaultExpression('CURRENT_TIMESTAMP'),
'updated_by' => $this->integer(11)->notNull()->defaultValue(0),
'updated_by' => $this->integer(11)->null(),
], $tableOptions);

$this->createIndex('{{%idx-pages-alias}}', '{{%pages}}', ['name', 'alias']);
Expand Down
12 changes: 7 additions & 5 deletions views/pages/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'id' => "addPageForm",
'enableAjaxValidation' => true
]); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true, 'lang' => ($model->locale ?? Yii::$app->language)]) ?>

<?= $form->field($model, 'alias')->widget(AliasInput::class, [
'labels' => [
Expand All @@ -60,7 +60,9 @@
?>

<?= $form->field($model, 'content')->widget(Editor::class, [
'options' => [],
'options' => [
'lang' => ($model->locale ?? Yii::$app->language)
],
'pluginOptions' => []
]) ?>

Expand Down Expand Up @@ -99,9 +101,9 @@
</div>
<div id="pageMetaTags" class="panel-collapse collapse">
<div class="panel-body">
<?= $form->field($model, 'title')->textInput() ?>
<?= $form->field($model, 'description')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'keywords')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'title')->textInput(['lang' => ($model->locale ?? Yii::$app->language)]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 3, 'lang' => ($model->locale ?? Yii::$app->language)]) ?>
<?= $form->field($model, 'keywords')->textarea(['rows' => 3, 'lang' => ($model->locale ?? Yii::$app->language)]) ?>
</div>
</div>
</div>
Expand Down
28 changes: 25 additions & 3 deletions views/pages/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
[
'attribute' => 'name',
'format' => 'raw',
'contentOptions' => [
'lang' => ($model->locale ?? Yii::$app->language)
],
'value' => function($model) {
$output = Html::tag('strong', $model->name);
if (($pageURL = $model->getPageUrl(true, true)) && $model->id) {
Expand All @@ -56,16 +59,35 @@
return $output;
}
],
'title:ntext',
[
'attribute' => 'title',
'format' => 'ntext',
'contentOptions' => [
'lang' => ($model->locale ?? Yii::$app->language)
]
],
[
'attribute' => 'content',
'format' => 'html',
'contentOptions' => [
'lang' => ($model->locale ?? Yii::$app->language),
'style' => 'display:inline-block;max-height:360px;overflow-x:auto;'
]
],
'description:ntext',
'keywords:ntext',
[
'attribute' => 'description',
'format' => 'ntext',
'contentOptions' => [
'lang' => ($model->locale ?? Yii::$app->language)
]
],
[
'attribute' => 'keywords',
'format' => 'ntext',
'contentOptions' => [
'lang' => ($model->locale ?? Yii::$app->language)
]
],
[
'attribute' => 'common',
'label' => Yii::t('app/modules/pages','Common'),
Expand Down

0 comments on commit a3cd30c

Please sign in to comment.