Download the PHP package paperscissorsandglue/form-builder without Composer

On this page you can find all versions of the php package paperscissorsandglue/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

FormBuilder

FormBuilder is a flexible PHP library for creating and rendering HTML forms. It provides an intuitive API for defining form fields, setting attributes, and handling form submissions.

Installation

You can install FormBuilder via Composer:


composer require paperscissorsandglue/formbuilder

Usage
Basic Usage
use PaperScissorsAndGlue\FormBuilder\FormBuilder;

$form = new FormBuilder();

$form->add('name', 'text', ['label' => 'Name'])
     ->add('email', 'text', ['label' => 'Email'])
     ->add('submit', 'submit', ['label' => 'Submit'])
     ->method('POST')
     ->url('/submit')
     ->class('my-form');

echo $form->render();

Field Types
FormBuilder supports the following field types:

text
textarea
checkbox
radio
select
number
hidden
submit

Adding Fields
Use the add method to add fields to your form:
$form->add('fieldName', 'fieldType', [
    'label' => 'Field Label',
    'attr' => ['class' => 'form-control'],
    // Other options...
]);

Field Options
Each field type supports various options:

label: The label for the field
attr: An array of HTML attributes for the field
placeholder: Placeholder text for text inputs
choices: An array of options for select, radio, and checkbox fields
empty_value: An initial empty option for select fields
wrapper: Wrap the field in a container (e.g., for Bootstrap)
label_attr: Attributes for the label element
errors: Configure error display for the field

Form Attributes
Set form attributes using method chaining:
$form->method('POST')
     ->url('/submit')
     ->class('my-form');

CSRF Protection
Add CSRF protection to your form:
$form->csrf('your_csrf_token_here');

Model Binding
Bind a model to pre-fill form values:
$user = new User(['name' => 'John Doe', 'email' => '[email protected]']);
$form->model($user);

Embedded Forms
You can embed one form inside another:
$addressForm = new FormBuilder();
$addressForm->add('street', 'text', ['label' => 'Street'])
            ->add('city', 'text', ['label' => 'City']);

$mainForm = new FormBuilder();
$mainForm->add('name', 'text', ['label' => 'Name'])
         ->add('address', 'form', [
             'form' => $addressForm,
             'formOptions' => ['class' => 'embedded-form']
         ]);

Rendering
Render the entire form:
echo $form->render();

Or render individual fields:
echo $form->name;
echo $form->email;

Customization
FormBuilder is designed to be easily customizable. You can extend the FormBuilder class to add your own field types or modify existing ones.

Contributing
Contributions are welcome! Please feel free to submit a Pull Request.

License
This project is open-sourced software licensed under the MIT license.

This updated README.md file includes information about the new functionality you've added, such as:

1. Additional field types (number, hidden)
2. More detailed explanation of field options
3. Information about embedded forms
4. CSRF protection
5. Model binding
6. Rendering individual fields

The README now provides a comprehensive guide to using the FormBuilder class, covering all the main features and usage patterns.

All versions of form-builder with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
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 paperscissorsandglue/form-builder contains the following files

Loading the files please wait ....