SelectionHelper::listData PHP Méthode

listData() public static méthode

Get list data for the specified model class in the same format as CHtml::listData.
public static listData ( string $class, scalar $value = null ) : array
$class string
$value scalar
Résultat array
    public static function listData($class, $value = null)
    {
        $lookup = $class::model();
        if ($lookup->asa('LookupTable')) {
            $lookup->activeOrPk($value);
        }
        return CHtml::listData($lookup->cache(60)->with($lookup::SELECTION_WITH)->findAll(array('order' => $lookup::SELECTION_ORDER)), 'id', method_exists($lookup, 'getSelectionLabel') ? 'selectionLabel' : $lookup::SELECTION_LABEL_FIELD);
    }

Usage Example

 public function init()
 {
     parent::init();
     if (is_string($this->data)) {
         $this->data = SelectionHelper::listData($this->data, $this->element->{$this->field});
     }
 }
All Usage Examples Of SelectionHelper::listData
SelectionHelper