Reputation: 13
Have a website and form to search. Dont know where to find file, where I can change text on my "Reset" button. For example change to "Erase all".
Now i have this button with text:"Reset" I tried to search in "yii\widgets\ActiveForm" and "kartik\select2\Select2" files. But could not find.
<?php
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\search\ProductSearch */
/* @var $form yii\widgets\ActiveForm */
/* @var $dataProvider yii\data\ActiveDataProvider */ ?>
<div class="col-sm-12">
<div class="gadget-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'options' => [
'data-pjax' => true,
'id' => 'wow',
'class' => 'form-inline',
],
]); ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('app', 'Reset'), Url::toRoute([]), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
Upvotes: 1
Views: 2937
Reputation: 7886
Yii::t('app', 'Reset')
is the text outputted on the reset button. you can replace it directly:
<?= Html::a("Erase all", Url::toRoute([]), ['class' => 'btn btn-default']) ?>
but that will break you translation. To change it properly you'll need to check the i18n application component configs to see to which file that app
category is pointing. If it was built following official docs then it may look like this:
'components' => [
// ...
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
//'basePath' => '@app/messages',
//'sourceLanguage' => 'en-US',
'fileMap' => [
'app' => 'app.php',
'app/error' => 'error.php',
],
],
],
],
],
That app.php
file hosted under @app/messages
should return an array. Find the Reset
key there and change its text or alternatively add Erase all
as a new key with its equivalent translation text in all related languages files then call it using Yii::t('app', 'Erase all')
.
Upvotes: 3