Reputation: 3864
In my _form.php I am trying to change the default form title.
Actually what I want to change the text in Bold -Create City to Create Custom City
To achieve this I am trying this code, but I am getting the error like - Unable to locate message source for category 'City'.
example1
<?php
$this->title = Yii::t('City','Custom City');
?>
example 2- I am not getting any error, but the form title is also not changed.
<?php
$this->title = 'Custom City';
?>
I am putting below the whole code of _form.php
:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\City */
/* @var $form 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>
Upvotes: 4
Views: 4105
Reputation: 2790
You can set or change the title of _form.php from create.php.
Which means you can find in your create.php
$this->title = 'Create City';
which can be changed to anything.
Upvotes: 3