generateLabels() public method

Generates the attribute labels for the specified table.
public generateLabels ( yii\db\TableSchema $table ) : array
$table yii\db\TableSchema the table schema
return array the generated attribute labels (name => label)
Example #1
0
 /** Added by pafnow
  * Generates the attribute labels for the specified table.
  * @param \yii\db\TableSchema $table the table schema
  * @return array the generated attribute labels (name => label)
  */
 public function generateLabels($table)
 {
     $table_clone = clone $table;
     foreach ($table_clone->columns as $key => $column) {
         $column_clone = clone $column;
         $table_clone->columns[$key] = $column_clone;
         if (!empty($column->comment)) {
             $table_clone->columns[$key]->comment = Json::getValue($column->comment, "label", false, $column->comment);
         }
     }
     return parent::generateLabels($table_clone);
 }
Example #2
0
 public function generateLabels($table)
 {
     $labels = parent::generateLabels($table);
     array_walk($labels, function (&$value) {
         if (substr_compare($value, ' id', -3, 3, true) === 0) {
             $value = substr($value, 0, -3);
             // remove ID
         }
         $value = ucfirst(strtolower($value));
     });
     return $labels;
 }