yii\grid\ActionColumn::createUrl PHP Method

createUrl() public method

This method is called for each button and each row.
public createUrl ( string $action, ActiveRecord $model, mixed $key, integer $index ) : string
$action string the button name (or action ID)
$model yii\db\ActiveRecord the data model
$key mixed the key associated with the data model
$index integer the current row index
return string the created URL
    public function createUrl($action, $model, $key, $index)
    {
        if (is_callable($this->urlCreator)) {
            return call_user_func($this->urlCreator, $action, $model, $key, $index, $this);
        } else {
            $params = is_array($key) ? $key : ['id' => (string) $key];
            $params[0] = $this->controller ? $this->controller . '/' . $action : $action;
            return Url::toRoute($params);
        }
    }

Usage Example

Example #1
0
 public function createUrl($action, $model, $key, $index)
 {
     if (method_exists($model, 'getUrl') && ($url = $model->getUrl($action)) && !$this->urlCreator) {
         return $url;
     } else {
         return parent::createUrl($action, $model, $key, $index);
     }
 }
All Usage Examples Of yii\grid\ActionColumn::createUrl