1. Go to this page and download the library: Download apility/form-builder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
apility / form-builder example snippets
namespace App\Providers;
use Netflex\FormBuilder\Fields\TextInput;
use Netflex\FormBuilder\Interfaces\FormFieldRepository;
use \Netflex\FormBuilder\Providers\FormBuilderServiceProvider as FormBuilderBaseServiceProvider;
class FormBuilderServiceProvider extends FormBuilderBaseServiceProvider
{
function boot(FormFieldRepository $repo)
{
$repo->registerField('text', TextInput::class);
}
}
namespace App\Models;
use Illuminate\Routing\Router;
use Netflex\FormBuilder\Interfaces\FormModel;
use Netflex\FormBuilder\Traits\DefaultFormFieldName;
use Netflex\Structure\Model;
class Form extends Model implements FormModel
{
use DefaultFormFieldName;
/**
* The directory_id associated with the model.
*
* @var int
*/
protected $relationId = 12345;
//
public function getFormAttributeKey(): string
{
return "fields";
}
public function getErrorBagName(): string
{
return "form";
}
}
namespace Netflex\FormBuilder\Fields;
class TextInput extends BaseField
{
public $ {
return $this->question ?? "Question is missing";
}
public function formDescription(): ?string
{
return $this->description;
}
function formValidators(): array
{
return $this->ption' => $this->description
]);
}
}
/// Find some entry based on whatever criteria you want
$form = MyFormModel::find(12345);
namespace App\Http\Requests\FormBuilder;
use Illuminate\Foundation\Http\FormRequest;
use Netflex\FormBuilder\Interfaces\Form;
use Netflex\FormBuilder\Interfaces\FormModel;
use Netflex\FormBuilder\Requests\FormBuilderRequest;
class NormalFormRequest extends FormBuilderRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
public function rules() {
return [
];
}
/**
*
* Resolve the same form that you used to render the submitted form
*
* @return FormModel|null
*/
function getForm(): ?FormModel
{
// TODO: Resolve form
}
}
shell
$ php artisan form-builder:install
shell
$ php artisan make:form-builder
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.