2017 © Pedro Peláez
 

yii2-extension yii2-require-modal

Yii2 links with form in modal dialog, opening on click.

image

alexgivi/yii2-require-modal

Yii2 links with form in modal dialog, opening on click.

  • Monday, July 16, 2018
  • by alexgivi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

yii2-require-modal

Widget for add form in modal dialog to links., (*1)

Readme на русском:, (*2)

Install

Preferrable way - via composer., (*3)

Execute, (*4)

php composer.phar require --prefer-dist alexgivi/yii2-require-modal "*"

or add, (*5)

"alexgivi/yii2-require-modal": "*"

to require section of composer.json file., (*6)

Usage

Widget for link with form:, (*7)

<?= \alexgivi\requireModal\RequireLink::widget([
    'text' => 'Complete form'
    'url' => ['test-controller/test-require'],
    'requireFormItems' => \alexgivi\requireModal\RequireHelper::compose()
         ->addDateField('date', 'Date', date('d.m.Y'))
         ->addNumberField('number', 'Number')
         ->addTextField('text', 'Text')
         ->addTextArea('textarea', 'Big Text')
         ->addDropDownList('selected', 'List', SomeClass::$someData)
]); ?>

In controller:, (*8)

class TestController extends yii\web\Controller
{
    public function actionTestRequire()
    {
        $date = Yii::$app->request->post('date');
        $number = Yii::$app->request->post('number');
        $text = Yii::$app->request->post('text');
        // ...
    }
}

Usage with models

Component can be used to implement model create / update forms in modal., (*9)

Widget for link with form:, (*10)

/**
 * @var $model SomeModel
 */

 ...

= \alexgivi\requireModal\RequireLink::widget([
    'text' => 'Update'
    'url' => ['some-model/update', 'id' => $model->id],
    'requireFormItems' => \alexgivi\requireModal\RequireHelper::compose()
         ->addActiveDateField($model, 'date_attribute',)
         ->addNumberField($model, 'number_field')
         ->addTextField($model, 'name')
         ->addTextArea($model, 'description')
         ->addDropDownList($model, 'type', SomeModel::$typeNames)
         ->addHiddenField('redirect', Yii::$app->request->url)
]); ?>

In controller:, (*11)

class SomeModelController extends yii\web\Controller
{
    public function actionUpdate($id)
    {
        $model = $this->loadModel($id);

        if ($model->load($_POST) && $model->save()) {
            return $this->redirect(isset($_POST['redirect']) ?
                $_POST['redirect'] : ['view', 'id' => $model->id]);
        }

        return $this->render('update', ['model' => $model]);
    }
}

For create new model:, (*12)

/**
 * @var $model SomeModel
 */


= \alexgivi\requireModal\RequireLink::widget([
    'text' => 'Create'
    'url' => ['some-model/create', 'id' => $model->id],
    'requireFormItems' => \alexgivi\requireModal\RequireHelper::compose()
         ->addActiveDateField($model, 'date_attribute',)
         ->addNumberField($model, 'number_field')
         ->addTextField($model, 'name')
         ->addTextArea($model, 'description')
         ->addDropDownList($model, 'type', SomeModel::$typeNames)
         ->addHiddenField('redirect', Yii::$app->request->url)
]); ?>

In controller:, (*13)

class SomeModelController extends yii\web\Controller
{
    public function actionCreate()
    {
        $model = new SomeModel();

        if ($model->load($_POST) && $model->save()) {
            return $this->redirect(isset($_POST['redirect']) ?
                $_POST['redirect'] : ['view', 'id' => $model->id]);
        }

        return $this->render('create', ['model' => $model]);
    }
}

The Versions

16/07 2018

dev-master

9999999-dev

Yii2 links with form in modal dialog, opening on click.

  Sources   Download

MIT

The Requires

 

by Alexey Gevondyan

extension yii2 form link require modal

16/07 2018

v1.0.3

1.0.3.0

Yii2 links with form in modal dialog, opening on click.

  Sources   Download

MIT

The Requires

 

by Alexey Gevondyan

extension yii2 form link require modal

16/07 2018

v1.0.2

1.0.2.0

Yii2 links with form in modal dialog, opening on click.

  Sources   Download

MIT

The Requires

 

by Alexey Gevondyan

extension yii2 form link require modal

13/07 2018

v1.0.1

1.0.1.0

Yii2 links with form in modal dialog, opening on click.

  Sources   Download

MIT

The Requires

 

by Alexey Gevondyan

extension yii2 form link require modal

13/07 2018

v1.0

1.0.0.0

Yii2 links with form in modal dialog, opening on click.

  Sources   Download

MIT

The Requires

 

by Alexey Gevondyan

extension yii2 form link require modal