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
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' ]
- checkbox
- color
- date
- file
- month
- multipleFile
- number
- password
- push (soon)
- radioButton
- range
- select
- selectMultiple
- textarea
- time
- url
- week
You can use the component dy-form
<dy-form :id="$formId" :user="$userModelObject">
<input type="submit">
</dy-form>
Check CHANGELOG for the changelog
To run tests use
$ composer test
If you discover any security related issues, please email p.pator@outlook.com or use the issue tracker of GitHub.
The MIT License (MIT). Please see License File for more information.