In my _form.php, I am trying to change the default form title.
Actually, what I want to change in the text in bold - Create a city before Create a custom city
To achieve this, I try to use this code, but I get the error: - Could not find the message source for the category "City".
example1
<?php
$this->title = Yii::t('City','Custom City');
?>
example 2- I do not get any errors, but the name of the form also does not change.
<?php
$this->title = 'Custom City';
?>
I put under all the code _form.php:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$this->title = ('Custom City');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-lg-3">
</div>
<div class="col-lg-5 col-lg-offset-1">
<div class="city-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'state_id')->DropDownList(ArrayHelper::map(State::find()->all(), 'id', 'state_name' ),
[ 'prompt' => 'Please Select' ])?>
<?= $form->field($model, 'city_name')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

Pawan source
share