PHPackages                             alexmigf/forma - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. alexmigf/forma

ActiveLibrary[API Development](/categories/api)

alexmigf/forma
==============

WordPress Admin simple form API package

1.0.0(3y ago)010GPL-3.0-or-laterPHPPHP &gt;=7.0

Since Dec 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/alexmigf/forma)[ Packagist](https://packagist.org/packages/alexmigf/forma)[ Docs](https://github.com/alexmigf/forma)[ RSS](/packages/alexmigf-forma/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

alexmigf\\forma
===============

[](#alexmigfforma)

WordPress Admin simple form API composer package

Requirements
------------

[](#requirements)

- PHP &gt;= 7.0
- WordPress &gt;= 4.4

Install
-------

[](#install)

```
composer require alexmigf/forma
```

Usage
-----

[](#usage)

Configure the form settings first

```
$args = [
	'title'        => 'My form title',                    // form title (default: '')
	'classes'      => '',                                 // additional CSS form classes (default: '')
	'action'       => '',                                 // file to process the form data (default: '')
	'method'       => 'post',                             // the form request method (default: 'post')
	'enctype'      => '',                                 // encoding type (default: 'application/x-www-form-urlencoded')
	'callback'     => null,                               // callback function to process the form data (default: null)
	'nonce'        => true,                               // nonce validation, if data is handled by this package (default: false)
	'button_text'  => 'Send',                             // submit button text (default: Send)
	'redirect_uri' => '',                                 // URL for redirection after submit (default: '')
	'messages'     => [ 'error' => '', 'success' => '' ], // form custom  messages (default: null)
];
```

Instantiate the form class by passing an ID and the configuration array

```
$forma = new Alexmigf\Forma( $id = 'new-form', $args );
```

Add sections to group multiple fields

```
$forma->add_section( $section_id = 'profile' );
```

Add single field

```
$field = [
	'type'     => 'text',
	'id'       => 'first_name',
	'label'    => __( 'First name', 'textdomain' ),
	'value'    => '',
	'required' => true,
];
$forma->add_field( $field, $section_id = 'profile' );

/* or */

$forma->add_field( $field ); // fields without section became 'orphans', non grouped
```

Add multiple fields at once

```
$fields = [
	[
		'type'     => 'text',
		'id'       => 'first_name',
		'label'    => __( 'First name', 'textdomain' ),
		'value'    => '',
		'required' => true,
	],
	[
		'type'     => 'text',
		'id'       => 'last_name',
		'label'    => __( 'Last name', 'textdomain' ),
		'value'    => '',
		'required' => true,
	],
	[
		'type'     => 'text',
		'id'       => 'company',
		'label'    => __( 'Company', 'textdomain' ),
		'value'    => '',
		'required' => false,
	],
	[
		'type'     => 'text',
		'id'       => 'position',
		'label'    => __( 'Position', 'textdomain' ),
		'value'    => '',
		'required' => false,
	],
	[
		'type'     => 'email',
		'id'       => 'email',
		'label'    => __( 'Email', 'textdomain' ),
		'value'    => '',
		'required' => false,
	],
	[
		'type'     => 'tel',
		'id'       => 'phone_number',
		'label'    => __( 'Phone number', 'textdomain' ),
		'value'    => '',
		'required' => false,
	],
];

$forma->add_fields( $fields, 'profile' );
```

Add custom hidden field

```
$forma->add_hidden_field( $name = 'custom_hidden_field', $value = '1' );
```

Add custom nonce field

```
$forma->add_nonce_field( $action = 'custom_nonce_action' );
```

Display the form

```
$forma->render();
```

Passing values to fields
------------------------

[](#passing-values-to-fields)

If you require to display the current saved data in the fields.

```
$data = $database->get_entries();
$forma->add_fields( form_fields( $data ), $section_id = 'profile' );

function form_fields( $data = [] ) {
	return [
		[
			'type'     => 'text',
			'id'       => 'first_name',
			'label'    => __( 'First name', 'textdomain' ),
			'value'    => isset( $data['first_name'] ) ? $data['first_name'] : '',
			'required' => true,
		],
		[
			'type'     => 'text',
			'id'       => 'last_name',
			'label'    => __( 'Last name', 'textdomain' ),
			'value'    => isset( $data['last_name'] ) ? $data['last_name'] : '',
			'required' => true,
		],
		[
			'type'     => 'text',
			'id'       => 'company',
			'label'    => __( 'Company', 'textdomain' ),
			'value'    => isset( $data['company'] ) ? $data['company'] : '',
			'required' => false,
		],
		[
			'type'     => 'text',
			'id'       => 'position',
			'label'    => __( 'Position', 'textdomain' ),
			'value'    => isset( $data['position'] ) ? $data['position'] : '',
			'required' => false,
		],
		[
			'type'     => 'email',
			'id'       => 'email',
			'label'    => __( 'Email', 'textdomain' ),
			'value'    => isset( $data['email'] ) ? $data['email'] : '',
			'required' => false,
		],
		[
			'type'     => 'tel',
			'id'       => 'phone_number',
			'label'    => __( 'Phone number', 'textdomain' ),
			'value'    => isset( $data['phone_number'] ) ? $data['phone_number'] : '',
			'required' => false,
		],
	];
}
```

Process callback
----------------

[](#process-callback)

If a form callback function is provided, the nonce validation is done inside the `alexmigf\forma` package, which returns the request data to be processed by the callback.

```
function new_form_process_callback( $request ) {
	// $request contains the data to be processed
	// do your stuff and return bool

	$response = false;
	if ( ! empty( $request ) ) {
		$response = $database->insert( $request );
	}
	return $response;
}
```

Supported field types
---------------------

[](#supported-field-types)

- hidden
- submit
- checkbox
- tel
- number
- email
- date
- select
- textarea
- url
- text
- file

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Total

2

Last Release

1204d ago

Major Versions

0.01 → 1.0.02023-01-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/59ba3e1bfdfea112318e4302677c2b28a6e034ac8638a25f6f95165b526609a4?d=identicon)[alexmigf](/maintainers/alexmigf)

---

Top Contributors

[![alexmigf](https://avatars.githubusercontent.com/u/533273?v=4)](https://github.com/alexmigf "alexmigf (8 commits)")

---

Tags

apiwordpressform

### Embed Badge

![Health badge](/badges/alexmigf-forma/health.svg)

```
[![Health](https://phpackages.com/badges/alexmigf-forma/health.svg)](https://phpackages.com/packages/alexmigf-forma)
```

###  Alternatives

[wp-graphql/wp-graphql-woocommerce

WooCommerce bindings for WPGraphQL

69146.8k](/packages/wp-graphql-wp-graphql-woocommerce)[wordpress/wp-ai-client

An AI client and API for WordPress to communicate with any generative AI models of various capabilities using a uniform API.

11117.5k1](/packages/wordpress-wp-ai-client)[rickwest/laravel-wordpress-api

A Laravel read-only client for the WordPress REST API (v2)

3712.5k1](/packages/rickwest-laravel-wordpress-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
