Download the PHP package digitalnodecom/larafields without Composer

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

Abstract Form Maker

A flexible form maker package that allows you to define custom form groups for WordPress posts and taxonomies.

Installation

You can install this package with Composer:

After installation, you need to:

  1. Clear the Acorn cache:

This step is necessary for the package to be recognized by Acorn.

  1. Publish the package assets and configuration:

  2. Run the database migrations:

  3. Build the JavaScript and CSS assets:

This step compiles the JavaScript and CSS files needed for the package to function properly.

  1. Add the following hooks to your current theme's functions.php file.

  2. Clear the cached views

Configuration

Form groups are defined in the config/larafields.php file. Each form group can be configured to display on specific post types or taxonomies.

Basic Structure

Core Concepts

The package uses several key terms throughout its configuration and API:

Object Types and Names

These concepts are used throughout the package's API and configuration to precisely target where fields should be displayed and how data should be stored and retrieved.

Display Conditions

You can display form groups on any Post Type, any Term, and/or create a custom Options page:

Post Type Display

This will display the form group on the specified post type's edit screen in the WordPress Admin dashboard.

Taxonomy Display

This will display the form group on the specified taxonomy's term edit screen in the WordPress Admin dashboard.

Options Page Display

This will create a new page in the WordPress Admin dashboard with the specified title and menu entry. The form group will be rendered on this custom options page.

Term Option Page Display

This will add an action link (alongside Edit, Quick Edit, Delete, View) on the taxonomy overview page. When clicked, it opens a custom page where the form group will be rendered, with the data being related to both the selected term and taxonomy.

User Profile Display

This will display the form group on the user's "Edit Profile" page in the WordPress Admin dashboard.

User Page Display

This will add an action link (alongside Edit, Delete, and other user actions) on the Users overview page. When clicked, it opens a custom page where the form group will be rendered for the selected user.

Available Field Types

Text Field

Simple text input with optional character limit.

Date Field

Date picker input field.

DateTime Field

Date and time picker input field.

Week Field

Week picker input field.

Month Field

Month picker input field.

File Field

File upload field with image preview support. Files are stored in the default disk under the 'larafields' directory.

Textarea Field

Multiline text input with optional character limit.

Number Field

Numeric input with optional min/max values.

Multiselect Field

Dropdown field that allows selecting multiple options.

When custom_values is set to true, users can enter and select values that are not predefined in the options list. This is useful when you want to allow for flexible input while still providing common options.

Repeater Field

Group of fields that can be repeated multiple times.

Adding Field Groups Programmatically

You can programmatically add new field groups using the FormMaker::add_group() method. This can be added to an action hook in your theme or plugin:

The structure follows the same format as defined in the configuration file, allowing you to specify labels, settings, and fields for your new group.

Retrieving Field Data Programmatically

You can fetch field data from the database using the FormMaker::get_field() method. This method accepts three optional parameters:

At least one of these parameters must be provided:

The method will throw an Exception if none of these parameters are provided.

Example usage:

Extending Fields

You can modify or manipulate the existing fields using the larafields_load_fields WordPress filter. This filter provides access to the fields collection before it's processed:

Dashboard Menu Pages

You can add custom dashboard menu pages using the larafields_load_pages filter. This allows you to create additional admin pages for your application.

Adding Dashboard Menu Pages

Use the larafields_load_pages filter to add new pages to the WordPress admin dashboard:

JavaScript Bundling

This package uses webpack to bundle JavaScript dependencies. The main JavaScript dependency is tom-select, which is used for the multiselect field type.

Development

To work on the JavaScript files:

  1. Make changes to the JavaScript files in the resources/js directory
  2. Run npm run dev to watch for changes and automatically rebuild the JavaScript files

Production

To build the JavaScript files for production:

  1. Run npm run build to build both CSS and JavaScript files
  2. The bundled JavaScript file will be available at resources/js/public/larafields.js
  3. The tom-select CSS file will be available at resources/js/public/css/tom-select.css

API Documentation

The package provides REST API endpoints for querying and updating forms and their data.

Query Endpoint

Authentication

The API uses Basic Authentication with WordPress Application Passwords:

Request Body Parameters

The endpoint accepts the following parameters in the request body:

Parameter Required Description
object_id No* The ID of the object (post, term, etc.)
object_name No* The name of the object type
field_key No* The key of the specific field to retrieve

*At least one of these parameters must be provided.

Field Validation

The API implements the following validation rules:

This means you must provide at least one of these three parameters in your request.

Query Examples

Query by Object ID

This will return all form data associated with the object ID 123.

Query by Object Name

This will return all form data associated with the object type "product".

Query by Field Key

This will return the specific field data for the field key "product_gender".

Combined Query

This will return form data that matches both the object ID 123 and object type "product".

Update Endpoint

Authentication

The API uses Basic Authentication with WordPress Application Passwords (same as the Query Endpoint).

Request Body

The request body should be a JSON object with the following properties:

Property Required Description
field_key Yes The key of the field to update
field_value Yes The new value for the field
object_id Yes The ID of the object (post, term, etc.)
object_name Yes The name of the object type

Example Request

Response

A successful update will return a JSON response with status 'ok':

Complete Examples

Post Type Form Group

Taxonomy Form Group


All versions of larafields with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
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 digitalnodecom/larafields contains the following files

Loading the files please wait ....