Download the PHP package apility/form-builder without Composer

On this page you can find all versions of the php package apility/form-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package form-builder

Apility Form Builder for Laravel

Installation

Add the form builder to your composer file

Create a new Service provider that extends the Netflex\FormBuilder\Providers\FormBuilderServiceProvider

Will generate a new service provider remember to register it.

Basic example.

The registerField method registers a question/field type that can be rendered by the form builder. You can implement your own (see the section below for instructions). The class that is provided must implement the Netflex\FormBuilder\Interfaces\FormField class.

We do have a basic implementation that comes with prefilled working bookkeeping functionality such as formModel and name injection, as well as hoisting values from the matrix field data into the model as attributes.

It might be quicker to use this than implementing similar functionality manually.

Check out the Netflex\FormBuilder\Fields\BaseField class.

Overrides

It is possible to override data coming from Netflex using an optional 3rd parameter to the registerField function. You can supply an optional associative array to the function like this

This is merely substituting any values from Netflex with these, that way you can omit fields that are configurable in the class, but not something the user should be able to change. Or lets you create reusable field types that can be configured when added.

It is possible to add the same class more than once.

Add the service providers to your bootstrap/app.php

One of these is the one you made yourself, the other provides views.

Have your form model implement the FormModel interface

The getFormAttributeKey should be the same as the alias of the Matrix that contains the questions for the form. The getErrorBagName function decides where the validation errors for FormBuilderRequests go, this should often be something other than default.

DefaultFormFieldName trait

The model must decare some values which are considered to be menial bookkeeping and not something the developer really should need to care about except for very specific cases. This trait implements this functionality so the developer does not have to.

What it does is default the named prefix for all fields to be "questions". If you want to rename this field, implement the relevant methods manually.

Implementing custom field types

The Class

In order to create your own field type, create a new class that extends the Netflex\FormBuilder\Fields\BaseField class. This is both a Laravel view and a special field class that requires you to extends certain variables.

The BaseField class, represents a question in your form and is instantiated once for each

QOL tips

The View

They are basically normal components It is recommended that you use the view() function when rendering these components.

Usage

This package is intended to transform Netflex Structure entries into forms using a matrix field. It provides some simple components for rendering forms components and validating them.

You must supply your own <form> tags and backend functionality after the form request has been verified. The indented ide here is that we provide functionality that handles all form specific things, but does still let's you use laravel for other non form related things in an organic way.

To get started first create a form using any structure that has a model that implements the FormModel interface.

Rendering forms

You can render a simple form like this.

You wrap a <x-form-builder::form> component in a form tag.
That is it.

It is still possible to add your own input fields that are not part of the form. You will need to manually parse them, but it is still possible.

Show all errors for the form

Sometimes you want a big alert that gives you a list of all failing validation errors when a user submitted a form and it failed to pass validation. Use the <x-form-builder::validation-errors> component for that.

Slot

The <x-form-builder::validation-errors> component has a slot that lets you input text and similar right above the list of validation errors, inside the alert.

Built in Form fields

The library comes with some built in Bootstrap 5 compatible fields for quick and dirty forms.

Text Input (Netflex\FormBuilder\Fields\TextInput)

All arguments can be controlled from Netflex if added to the matrix block definition

Arguments

Name Description
question The question that will be shown in the field label
description Help text shown beneath the input field
required Boolean value that describes if the field is required
placeholder Input placeholder value
formType sets the type="text" part of the tag with alternatives such as phone and email

Internationalization

The following internationalization keys are used by this field

Numeric Text Field (Netflex\FormBuilder\Fields\NumericTextInput)

This text field is forced to be a number field. It also validates number ranges on the backend Placeholder is set to an i18n value that indicates potential top/bottom bounds of valid options.

Arguments

Name Description
question The question that will be shown in the field label
description Help text shown beneath the input field
required Boolean value that describes if the field is required
min Numeric field for a minimum value, not required
max Numeric field for a maximum value, not required
step Number step fields

Internationalization

The following internationalization keys are used by this field

TextArea (Netflex\FormBuilder\Fields\TextArea)

A multiline text area

Arguments

Accepts all the same fields as TextInput (except from formType), but also

Name Description
columns How many columns high the text area is, defaults to 10

Internationalization

The following internationalization keys are used by this field

Checkbox (Netflex\FormBuilder\Fields\Checkbox)

Displays a single checkbox. If required, the box must be checked to proceed. This is mostly used for confirmation boxes.

Arguments

Name Description
question The question that will be shown in the field label
description Help text shown beneath the input field
required Boolean value that describes if the field is required
labelText Text that is shown next to the checkbox, uses question if left blank

Internationalization

The following internationalization keys are used by this field

Select (Netflex\FormBuilder\Fields\Select)

Shows a dropdown of preselected values

Arguments

Name Description
question The question that will be shown in the field label
description Help text shown beneath the input field
required Boolean value that describes if the field is required
labelText Text that is shown next to the checkbox, uses question if left blank
options List of options separated by newline, potentially use the TextArea type in netflex

Internationalization

The following internationalization keys are used by this field

Form Validation

The package comes with a juiced up Laravel HTTP class that can automatically validate form fields. This allows you to specify validation logic per component and not have to deal with it, as long as you use laravel form requests.

works similarilly to make:request and will create a standard request.

Basic example

The getForm method must return the same form that was used to render the submitted form. Personally, I like using url parameters for this. That way we can use the Route parameter injection in


All versions of form-builder with dependencies

PHP Build Version
Package Version
Requires netflex/sdk Version ^4
netflex/structures Version ^4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package apility/form-builder contains the following files

Loading the files please wait ....