peterzaccha / dy-form
Dynamic Form Generator
v1.1.4
2019-09-24 13:59 UTC
Requires
- php: ^7.2
- appstract/laravel-blade-directives: ^1.4
- illuminate/support: 5.8.*
- spatie/laravel-blade-x: ^2.2
README
Installation
You can install the package via composer:
composer require peterzaccha/dy-form
If you are using Laravel in a version < 5.5, the service provider must be registered as a next step:
// config/app.php 'providers' => [ ... Peterzaccha\DyForm\DyFormServiceProvider::class ];
You can publish the views ,migrations and config by running :
php artisan vendor:publish --provider="Peterzaccha\DyForm\DyFormServiceProvider"
php artisan migrate
Warning
⚠️ This documentation ins INCOMPLETE! Please use on your own, or wait until it's ready! ⚠️
Usage
Creating Forms
$form = Dy::create(['name'=>'myForm']);
Creating Columns
$column = Dy::createColumn(['name'=>'myColumn','label'=>'My Column','render_type'=>'text']);
Add columns to the form
Dy::addColumn($form,$column);
Add options to column
Dy::addOption($column,Dy::createOption(['name'=>'one','value'=>'1']));
Submit form
Dy::submit($user, \Peterzaccha\DyForm\Models\DyForm::find(1),[ 'columnName' => 'column value', ]); //or from request Dy::submit($user, \Peterzaccha\DyForm\Models\DyForm::find(1),$request->all());
Using CanSubmit trait
<?php namespace App; use Peterzaccha\DyForm\Traits\CanSubmit; class User extends Authenticatable { use CanSubmit; }
Now you can do
use Peterzaccha\DyForm\Models\DyColumn; $column = DyColumn::find(1); $user->getColumnValue($column); //return the user submitted value in that column
use Peterzaccha\DyForm\Models\DyForm; $form = DyForm::find(1); $user->getFormValues($form); //return [ 'colum1'=>'value1' , 'column2'=>'value2' ]
Render Types
- checkbox
- color
- date
- file
- month
- multipleFile
- number
- password
- push (soon)
- radioButton
- range
- select
- selectMultiple
- textarea
- time
- url
- week
Render
You can use the component dy-form
<dy-form :id="$formId" :user="$userModelObject"> <input type="submit"> </dy-form>
Changelog
Check CHANGELOG for the changelog
Testing
To run tests use
$ composer test
Contributing
Security
If you discover any security related issues, please email p.pator@outlook.com or use the issue tracker of GitHub.
About
License
The MIT License (MIT). Please see License File for more information.