mhunesi/yii2-formio

Yii2 Formio Extension

Installs: 475

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 1

Type:yii2-extension

v0.0.1 2020-04-28 00:25 UTC

This package is auto-updated.

Last update: 2024-03-15 14:18:26 UTC


README

yiisoft.png

Yii Formio Module


The package bundle of Form.io plugin. Form.io is a plain JavaScript form renderer.

JavaScript powered Forms with JSON Form Builder https://formio.github.io/formio.js

Examples

Installation

Add the the package to your composer file:

composer require mhunesi/yii2-formio

The last thing you need to do is updating your database schema by applying the migrations. Make sure that you have properly configured db application component and run the following command:

    yii migrate --migrationPath=@mhunesi/formio/migrations

Add the modules to your application configuration file:

'modules' => [
    // ...
    'formio' => [
        'class' => \mhunesi\formio\Module::class,
        'userModel' => 'app/models/User'
    ],
    // ...
]

Usage

If you want Using Only Formio Widget:

<?= FormioWidget::widget([
    'id' => 'example',
    'action' => Url::to(['example/create']),
    'thanksPage' => Url::to(['example/create']),
    'submission' => [
        'firstName' => 'Mustafa'
    ],
    'query' => [
        'components' => [
            [
                'type' => 'textfield',
                'key' => 'firstName',
                'label' => 'First Name',
                'placeholder' => 'Enter your first name.',
                'input' => true,
                'tooltip' => 'Enter your <strong>First Name</strong>',
                'description' => 'Enter your <strong>First Name</strong>',
            ],
            [
                'type' => 'button',
                'action'  => 'submit',
                'label' => 'Submit',
                'theme' => 'primary'
            ]
        ]
    ],
    'clientOptions' => [
        'hooks' => [
            'beforeSubmit' => new JsExpression("
                (submission, next) => {
                    if(confirm('Are you sure?')){
                        next();
                    }
                }"
            )
        ]
    ]

]) ?>

Or you can use Form.io Builder and:

$form = Forms::findOne(8);

$form->render([
    'thanksPage' => Url::to(['example/thanks']),
]);

Screenshots

screen-1

All Screenshots...

Built by mhunesi