1

我的 StudentsForm 模型中有以下代码:

public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'sname' => 'Name',
            'fill' => ' Date',
        );
    }

在我的模型中的 TeacherForm 中:

 public function attributeLabels()
        {
            return array(
                'id' => 'ID',
                'tname' => ' Teacher Name',
                'fill' => ' Date',
            );
        } 

如何在 TeachersForm 中调用 StudentForm 的 attributeLabels()。两种型号都位于一个型号中

4

2 回答 2

1

您可以通过 2 种方法进行尝试。

  1. 通过 yii 方法
  2. 通过使用 oop

第一种方法。

$studentLable = StudentsForm::model()->attributeLabels();

第二种方法。

$studentModel = new StudentsForm;

$studentLable = $studentModel->attributeLabels();
于 2016-11-04T10:11:57.070 回答
1

只需使用这个

$lables = StudentsForm::model()->attributeLabels();

$lables将是一个array

$lables = array(
            'id' => 'ID',
            'sname' => 'Name',
            'fill' => ' Date',
        );
于 2016-11-04T10:02:24.757 回答