Download the PHP package hynek/hynek-form without Composer

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

Laravel Form Package

This package provides a robust and flexible way to build and render forms in your Laravel applications. It offers a clear, object-oriented approach to defining your form structures, controls, and presentation.

Installation

You can install the package via Composer:

After installing, publish the package's configuration file and views (optional) using:

This will publish config/form.php and resources/views/vendor/form to your application.

Configuration

The package's configuration file, config/form.php, allows you to customize the default classes and views used for various form components.

Here's a breakdown of the available configuration options:

Usage

The core of this package revolves around the FormBuilder interface, which defines the methods for constructing your forms. You will typically interact with an implementation of this interface to define your forms.

Basic Form Creation

To create a new form, you would usually instantiate the FormBuilder (or its concrete implementation) and chain its methods.

FormBuilder Methods

The FormBuilder interface provides the following methods for building your forms:

addAttribute(string|array $name, ?string $value = null): static

Adds HTML attributes to the form element.

removeAttribute(string $name): static

Removes an HTML attribute from the form element.

container(ElementContainer $container): static

Sets the container for the element. This allows you to wrap your form elements in custom HTML structures.

name(string $name): static

Sets the name of the form element. (Useful for the form itself if it's treated as an element).

id(string $id): static

Sets the HTML id attribute of the form element.

view(string $view): static

Sets a custom Blade view for rendering the element.

getName(): ?string

Gets the name of the form element.

getContainer(): ?ElementContainer

Gets the container of the form element.

action(string $action): static

Sets the action attribute for the form.

method(string $method): static

Sets the method attribute for the form (e.g., POST, GET).

element(FormElement $element): static

Adds a form element (like an input, textarea, or select) to the form.

getElements(): ElementsCollection

Retrieves a collection of all form elements added to the builder.

getRules(): Collection

Retrieves the validation rules associated with the form's elements. (Implementation dependent on how rules are attached to FormElement instances).

button(string $text, ?string $type = 'button'): static

Adds a button to the form.

getButtons(): ButtonsCollection

Retrieves a collection of all buttons added to the form.

enableAjax(): static

Enables AJAX/XHR submission for the form. This would typically add a specific attribute or class that your JavaScript can hook into.

disableAjax(): static

Disables AJAX/XHR submission for the form.

livewireSubmit(string $livewireSubmit): static

Integrates with Livewire by setting a wire:submit attribute on the form.

updateValue($elementName, $value): static

Updates the value of a specific form element.

Rendering Forms

Once you've constructed your form using the FormBuilder, you can render it in your Blade templates:

In your controller, you would pass the constructed form to the view:

Extending and Customizing

Custom Form Controls

You can create your own custom form controls by extending the Hynek\Form\Controls\Control class (or any existing control) and implementing the necessary methods. Once created, you can register your custom control in the config/form.php file under the controls array.

Then, in config/form.php:

Custom Views

If you've published the package's views, you can directly modify them in resources/views/vendor/form. Alternatively, you can create entirely new views and update the views array in config/form.php to point to your custom templates.

Custom Containers

Similar to controls, you can extend Hynek\Form\FormContainer or Hynek\Form\ControlContainer to create custom wrappers for your forms or individual controls. Then, update the default_form_container or default_control_container in your config/form.php.

3rd-party libraries

PHP / Laravel


All versions of hynek-form with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
hynek/hynek-macro Version dev-main
hynek/hynek-module-tools Version dev-main
livewire/flux Version ^2.2
livewire/livewire Version ^3.6
spatie/laravel-data Version ^4.17
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 hynek/hynek-form contains the following files

Loading the files please wait ...