2017 © Pedro Peláez
 

yii2-extension yii2-renderdual

Make your actions compatible for Ajax requests

image

felixmaier1989/yii2-renderdual

Make your actions compatible for Ajax requests

  • Sunday, July 26, 2015
  • by felixmaier1989
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2-RenderDual

Make your actions compatible for Ajax requests, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist felixmaier1989/yii2-renderdual "*"

or add, (*4)

"felixmaier1989/yii2-renderdual": "*"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by extending your controller:, (*6)

...
use yii2renderdual\RenderDual;

class SiteController extends Controller
{
    public function behaviors()
    {
        return [
            ...
            \yii2renderdual\RenderDual::className()
        ];
    }

    public function actionAbout()
    {
        Yii::$app->session->setFlash('success', 'Welcome on my home page');
        $fruits = ['banana', 'apple', 'jackfruit', 'papaya'];
        return $this->renderDual('about', compact('fruits'), true);
    }
...

An Ajax call to your site/about action would then return, (*7)

Array
(
    [flashes] => Array
        (
            [success] => Welcome on my home page
        )
    [params] => Array
        (
            [fruits] => Array
                (
                    [0] => banana
                    [1] => apple
                    [2] => jackfruit
                    [3] => papaya
                )

        )
    [rendered] => <h1>About</h1><p>I like banana, apple, jackfruit, papaya</p>
)

The Versions

26/07 2015

dev-master

9999999-dev

Make your actions compatible for Ajax requests

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar felixmaier1989

extension yii2 ajax request view action render

26/07 2015

1.0

1.0.0.0

Make your actions compatible for Ajax requests

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar felixmaier1989

extension yii2 ajax request view action render