Default Response Format

This somewhat relates to my earlier issue

I am learning more and more it is critical to set the Reponse Format when returning values from the controller, but I notice, the gii generated controller never specify the format?

In its simplest form, we have something like

    public function actionIndex()
        $searchModel = new ModelNameSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,

I’m just curious, should the Response Format be specified here as well?
Is there a default format applied when none is explicitly specified?
If so, what is it and where is it set?

Thank you for helping clarify this issue for me. Your assistance is greatly valued!$format-detail

Sorry for being slow, but I’ve seen/read that numerous times before and it still do not understand.

Are you saying that because in my example we are returning $this->render it is considered $content, thus no response format is required?
I guess I’m struggling to differentiate $data vs $content in the eyes of yii.

In case format isn’t set it’s considered HTML.

1 Like

Thank you.