Answer the question
In order to leave comments, you need to log in
Yii2. How to redefine the name of the input field on the form not by the name of the field in the database?
Hello dear experts!
I need to name the input fields on the form not by the name of the field in the database, but as I want. Example: there is a "name" field in the database, I need the name on the form of the input field to sound like "name10", but in the database the values are written exactly in the "name" field.
Can you please tell me how this can be implemented?
PS I'm new to yii2.
Answer the question
In order to leave comments, you need to log in
In the model:
public function getName10() {
return $this->name;
}
public function setName10($value) {
$this->name = $value;
}
$model->name10;
If you are interested in the name in the form label, then for this there is:
public function attributeLabels()
{
return [
'name' => 'Your name',
'email' => 'Your email address',
'subject' => 'Subject',
'body' => 'Content',
];
}
public $myvar;
public function setOldvar() {
return $this->oldvar = $this->myvar;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question