PHPackages                             motivast/motiforms - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. motivast/motiforms

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

motivast/motiforms
==================

Motiforms is a plugin provided for creating forms programmatically.

0.1.0(8y ago)8123[1 issues](https://github.com/motivast/motiforms/issues)GPL-2.0+PHPPHP &gt;=5.6.0

Since Nov 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/motivast/motiforms)[ Packagist](https://packagist.org/packages/motivast/motiforms)[ RSS](/packages/motivast-motiforms/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (27)Versions (2)Used By (0)

Motiforms [![Build Status](https://camo.githubusercontent.com/2264939fa0b56ffdbb9bc2dd3d703276a3f1b84efdbc59031ccbd4f17fe791d1/68747470733a2f2f7472617669732d63692e6f72672f6d6f7469766173742f6d6f7469666f726d732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/motivast/motiforms)
===============================================================================================================================================================================================================================================================================================

[](#motiforms-)

Motiforms is a WordPress plugin provided for creating forms programmatically using Symfony framework. If you do not need form builder and want to create advanced forms check out Motiforms.

Go to [get started](#user-content-get-started) section to see a simple example.

WARNING
-------

[](#warning)

If you are not developer this plugin is not for you. Motiforms do not provide any WordPress admin interface to creating forms.

Features
--------

[](#features)

- Handle form logic
- Field serialization
- Field validation
- Built in html rendering helpers
- Flexibility
- Based on advanced Symfony framework

Installation
------------

[](#installation)

1. Download plugin from wordpres.org repository or [release section](https://github.com/motivast/motiforms/releases/latest).
2. Upload the motiforms directory to your /wp-content/plugins/ directory
3. Activate the plugin through the ‘Plugins’ menu in WordPress

Get started
-----------

[](#get-started)

To create simple contact form paste code bellow to your functions.php file. And paste `[contact]` shortcode to your contact page.

```
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class ContactForm {

	/**
	 * Form instance
	 *
	 * FormType
	 */
	private $form;

	/**
	 * ContacForm constructor
	 *
	 * @return ContacForm
	 */
	public function __construct() {

		$this->define_hooks();
	}

	/**
	 * Create and process contact form
	 *
	 * This method is executed by wp action hook.
	 * It will be executed only on page which has contact
	 * shortcode.
	 *
	 * @return void
	 */
	public function controller() {

		global $post;

		// Check if current view is page and page has content shortcode
		if ( is_page() && has_shortcode( $post->post_content, 'contact' ) ) {

			$factory = mf_get_factory();

			// Create form
			$this->form = $factory->create();

			// Add fields to form
			$this->form->add( 'full_name', TextType::class );
			$this->form->add( 'email', EmailType::class );
			$this->form->add( 'message', TextareaType::class );
			$this->form->add( 'submit', SubmitType::class );

			// Get request object
			$request = mf_get_request();

			// Handle request
			$this->form->handleRequest( $request );

			// Check if form is valid
			if ( $this->form->isSubmitted() && $this->form->isValid() ) {

				// Get data from the form
				$data = $this->form->getData();

				// Define filters
				$filters = array(
					'full_name' => FILTER_SANITIZE_STRING,
					'email' => FILTER_SANITIZE_STRING | FILTER_SANITIZE_EMAIL,
					'message' => FILTER_SANITIZE_STRING,
				);

				// Fields sanitization
				$sanitized_data = filter_var_array( $data, $filters );

				// Perform action with form data e.g. send an e-mail

				// Redirect user with success parameter to prevent double submitting form
				wp_safe_redirect( $this->get_redirect_url() );
			}
		}
	}

	/**
	 * Render contact form.
	 *
	 * This method is executed by contact shortcode.
	 *
	 * @return string
	 */
	public function render() {

		$success =  filter_input( INPUT_GET, 'success', FILTER_SANITIZE_NUMBER_INT );

		if( '1' === $success ) {
			return sprintf('%s', __('Thank you for submitting the form. We will contact you shortly.') );
		}

		$form_view = $this->form->createView();

		$engine = mf_get_engine();

		return $engine['form']->form( $form_view, array('attr' => array('novalidate' => 'novalidate') ) );

	}

	/**
	 * Method executed by constructor to define hooks and
	 * create and render contact form.
	 *
	 * @return void
	 */
	private function define_hooks() {

		add_action( 'wp', array( $this, 'controller' ) );

		add_shortcode( 'contact', array( $this, 'render' ) );
	}

	/**
	 * Build url for form redirect
	 *
	 * @return string
	 */
	private function get_redirect_url() {

		$url = get_permalink();

		$query = parse_url($url, PHP_URL_QUERY);

		// Returns a string if the URL has parameters or NULL if not
		if ($query) {
			$url .= '&success=1';
		} else {
			$url .= '?success=1';
		}

		return $url;
	}
}

// Initialize contact form
new ContactForm();
```

Documentation
-------------

[](#documentation)

Documentation for Motiforms can be found on github [wiki pages](https://github.com/motivast/motiforms/wiki).

Contribute
----------

[](#contribute)

Please make sure to read the [Contribution guide](https://github.com/motivast/motiforms/blob/master/CONTRIBUTING.md) before making a pull request.

Thank you to all the people who already contributed to Motiforms!

License
-------

[](#license)

The project is licensed under the [GNU GPLv2 (or later)](https://github.com/motivast/motiforms/blob/master/LICENSE).

Copyright (c) 2017-present, Motivast

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.5% 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

Unknown

Total

1

Last Release

3104d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e61b64feaf64a3242ded3e06fb8734a63f953215af358b796c29e1c7e29f2bae?d=identicon)[kierzniak](/maintainers/kierzniak)

---

Top Contributors

[![kierzniak](https://avatars.githubusercontent.com/u/590020?v=4)](https://github.com/kierzniak "kierzniak (64 commits)")[![mbryne](https://avatars.githubusercontent.com/u/1341844?v=4)](https://github.com/mbryne "mbryne (1 commits)")

---

Tags

contactcontact-formformform-buildersymfonysymfony-formwordpresswordpress-plugin

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/motivast-motiforms/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

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