Download the PHP package seblhaire/formsbootstrap without Composer

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

FormsBootstrap

By Sébastien L'haire

A Laravel library to generate forms based on Boostrap 5 CSS Framework. RichText editor, and Icons provided by FontAwesome. Manages also results inputs of packages DateRangePickerHelper, Uploader, and Tags input. Package demo available here. Includes form management and validation.

Installation

  1. install package

composer require seblhaire/formsbootstrap See package documentations if you want to use related packages DateRangePickerHelper, Uploader and Tagsinput.

  1. Composer will automatically link the package with Laravel. But you still can explicitely add provider and facade to your config/app.php:

  2. Publish package (optionally).

  3. For Javascript and stylesheets, see next section.

Javascript and stylesheets

On a webpage, every JS library and CSS stylesheets can be linked separately. If you choose this classical way, first dowload and install jQuery and Bootstrap. Then publish package files as explained above and put following tags in your template:

Websites often use many libraries and stylesheets and browser must download many files before the site can be rendered properly. Modern websites come with a single compressed Javascript file which concatenates necessary scripts; same principle for stylesheets. With Laravel you can use Laravel Mix to compile files.

Use NPM package manager : npm install bootstrap jquery @fortawesome/fontawesome-free

Then your js source file should be something like this:

For your stylesheet:

Config files

Accessible through

Section formsbootstrap.classes contains class selectors that will be used for form validation, form reset etc. Section formsbootstrap.mandatory gives mandatory parameters for each form tag. Section formsbootstrap.editorTranslations contains translations for RichTextEditor. Finally section formsbootstrap.defaults contains default tag parameters.

In case you need change defaut values, use command php artisan vendor:publish and chose appropriate package in list. Then config files will be available in file config/vendor/seblhaire/.

Form tags

Templates have been defined in order to build forms rapidly in Laravel Blade templates. Example can be found in above mentionned demo site. The command that buils <form> tag is described in last subsection.

INPUT HIDDEN

Parameters:

INPUT TEXT

Parameters

Example

{!! Form::bsText(['id' => 'title', 'labeltext' => 'Title', 'required' => true]) !!}

INPUT NUMBER

Parameters

Example

{!! Form::Form::bsNumber([id' => 'number2', 'labeltext' => 'Number 2', 'value'=> 5, 'attributes' => ['min' => 0, 'max' => 10], 'helptext' => 'Please enter a number between 0 and 10', 'required' => true]);!!}

TEXTAREA

Parameters

Example

{!! Form::bsTextarea(['id' => 'notes', 'labeltext' => 'Notes', 'required' => true]) !!}

Editor

Parameters

Editor config

RichTextEditor can be parametrized by above config values. Editor can be initialized by several ways:

Default value is null

Lists

Title

Fonts

Uploads

Better use Uploader

Media

Link

Tables

Code

Colors

Dropdowns

Privacy

Developer settings

Example

INPUT EMAIL

Parameters

Email verification

Email fields can be automatically verified by regular expression. This expression can be found in config('formsbootstrap.defaults.email,email_regex'). It only verifies that a valid email address is used, but not that a mailbox exists and that the person who entered it in the form is its legitimate user.

If you want to check that the user that sent the form has access to the address, we suggest the standard verification procedure that is currently used by web application: in your main code, send an email which contains a link to a callback function in your code. Then email address is validated since the user must have access to the mailbox to read the validation mail. Laravel provides built-in services to verify email addresses.

Besides, in the form processing controller method, you should validate the email address on server side. Use something like this:

Emails can also be validated by 'email' => 'required|string|email:rfc'.

Javascript object

With this package, we provide a simple Javascript object that will be used by form validation. It is initalized automatically by our package.

If you need validate your field in a function, just call

Example

{!! Form::bsEmail[) !!}

INPUT PASSWORD

Two tag methods are available.

Default password rules are:

Common parameters to both methods

config('formsbootstrap.defaults.password_common') contains options available for the two methods;

Parameters of password alone

config('formsbootstrap.defaults.password') contains options for the unique password field:

Parameters of password with confirm

config('formsbootstrap.defaults.password-with-confirm') contains options for the password validation group:

Javascript object

With this package, we provide a simple Javascript object that will be used by form validation. It is initialized automatically by our package.

Object functions are called by input buttons or form validation but you can call them in other scripts:

Examples

{!! Form::bsPassword(['required' => true, 'validate' => false]) !!}

{!! Form::bsPasswordWithConfirm(['checkoldpassurl' => route('formsbootstrap_checkoldpass')]) !!}

SELECT

Parameters

Examples

{!! Form::bsSelect(['name' => 'priority', 'labeltext' => 'Priority', 'values' => ['lowest' => 'Lowest','low' => 'Low', 'medium' => 'Medium','high' => 'High','highest' => 'Highest'], 'default' => 'medium']) !!}

{!! Form::bsSelect(['name' => 'os', 'labeltext' => 'Operating system', 'values' => ['mac' => 'MacOs','windows' => 'Windows', 'linux' => 'Linux', 'vms' => 'Vms','unix' => 'Unix'], 'default' => 'linux', 'multiple' => true]) !!}

INPUT CHECKBOX

Parameters

Examples

{!! Form::bsCheckbox(['name' => 'os', 'values' => ['mac' => 'MacOs','windows' => 'Windows', 'linux' => 'Linux', 'vms' => 'Vms','unix' => 'Unix'], 'checkedvalues' => ['vms', 'mac'],'mainlabel' => 'Operating system']) !!}

{!! Form::bsCheckbox(['name' => 'languages', 'values' => ['en' => 'English', 'fr' => 'Français', 'de' => 'Deutsch', 'it' => 'Italiano', 'es' => 'Español', 'pt' => 'Português'], 'mainlabel' => 'Languages', 'switch' => true, 'required' => true]) !!}

{!! Form::bsCheckbox(['name' => 'conditions', 'values' => ['accepted' => 'I agree to terms and conditions'], 'required' => true, 'invalid-feedback' => "You must agree before submitting."]) !!}

INPUT RADIO

Parameters

Examples

{!! Form::bsRadio(['name' => 'priority', 'values' => ['lowest' => 'Lowest','low' => 'Low', 'medium' => 'Medium', 'high' => 'High','highest' => 'Highest'], 'checkedvalue' => 'medium', 'mainlabel' => 'Priority']) !!}

COLOR PICKER

Parameters

Example

{!! Form::bsColorpicker(['id' => 'color', 'labeltext' => 'Color', 'value' => '#ff0000']) !!}

RANGE

Parameters

Example

{!! Form::bsRange(['id' => 'range', 'labeltext' => 'Range', 'min' => 0, 'max' => 10, 'value' => "3", 'required' => true]); !!}

INPUT SUBMIT

Parameters

Example

{!! Form::bsSubmit([]) !!}

INPUT BUTTON

Parameters

Example

{!! Form::bsButton(['id' => 'cancel', 'action' => 'alert("cancel clicked");', 'label' => 'Cancel']) !!}

FORM

Form fields must be included between <form></form>. You just have to use the following functions. Then a Javascript object is created for form validation.

Form automatically inserts a hidden input that contains CSRF token. It also can insert automaticallly the submit button and optionally other buttons. And it can build a hidden alert div to contain form submit results.

Parameters

Form select classes

With jQuery, you can use classes to select elements. Eg jQuery('.verify') select all items in the current page that contain this class. You don't have to define CSS styles for these classes, but you can.

Required fields verification

These classes select elements that must not be empty:

Elements special verifications

Some form elements have special verification rules that verify well-formedness. These classes are automatically inserted when needed:

Form reset class

When form reset function is called, we select fields by following classes. These classes are automatically added to elements, except the last one:

With this package, we have built a Javascript object that processes form events, validates form and sends form results to a callback function. It is automatically initiallized with the parameter values.

jQuery('#form_complete').sebFormHelper({ ... })

Usually you don't have to call this object methods by yourself. Here we describe the public methods, though Javascrip does not allow to distinguish private, protected and public methods:

submit

This function can be used to submit form without pushing the usual submit button. This method validates the form before submitting it and then processes result:

Form success is evaluated first to see if we display an error message or go on with success callback actions.

Errors messages

validate

Validates the form, usually called by the submit function. Returns true when validation has passed but false if it fails. If you have defined the validate_function parameter, this callback function will also be called.

save

This method stores all fields content in an object property that is used to check if form values have been saved before the form user leaves the page.

isModified

This method checks if form data has been modified since last call of save() method. Returns true or false.

fillwithdata

You will probaly need to fill your form with existing data in your database that the form user needs to modify. First write a controller method linked to a route that returns the values you need in a Json object. Object keys must be the same as your form name and values must be compatible.

Then call this controller method with Ajax:

Then fields in your form with id corresponding with result keys will be filled. It also works with other compatible packages mentioned on this document top. If you have defined a function for the parameter filldatacallback, this callback will be used to fill other fields. Method save() is called after form has been filled.

removevalidation

This method just erases all validation messages.

reset

Resets the form, i.e. empties all values and reset the default ones. If parameter check_modified_on_reset is true, a confirmation box is displayed with tthe text of parameter modified_on_reset_confirm_text. If you have defined a callback function with parameter clear_function, it will be called as well.

errormessage

Displays error message in div before buttons.

successmessage

Displays success message in div before buttons.

alertresult

Display message in div before buttons, by overriding default values.

Example

Translation keys

Laravel loads config files very early in process. Thus config files cannot contain __('translation.key'). Therefore, we made an helper either to print directly strings or to send translation key to translation helper. Translation keys can be delimited by character #- Ex: "#formsbootstrap::messages.required#".

In templates, helper is called by eg: Form::translateOrPrint($data['oldpass']['labeltext']);

Feel free to translate keys in your own language and either to send it to the author or to do a merge request on GitHub.

Questions? Contributions?

Feel free to send feature requests or merge request to the author or simply to ask questions.


All versions of formsbootstrap with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
illuminate/http Version ^11.0
danielstjules/stringy Version ~3.1.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 seblhaire/formsbootstrap contains the following files

Loading the files please wait ....