2017 © Pedro Peláez
 

symfony-bundle form-bundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

image

xm/form-bundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  • Tuesday, October 24, 2017
  • by darrylhein
  • Repository
  • 2 Watchers
  • 0 Stars
  • 128 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 31 % Grown

The README.md

XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler., (*1)

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)

$ php composer.phar require xm/form-bundle

This command requires Composer., (*3)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new XM\FormBundle\XMFormBundle(),
        );

        // ...
    }
}

Step 3: Add Service Alias

Adding the following will make the call to the service shorter:, (*5)

form_handler: '@xm_form.handler'

Usage

Get the form handler

$formHandler = $this->get('form_handler');

Create the form

$form = $formHandler->getForm(
    EntityFormType::class,
    $entity,
    $request
);

Process form & save entity

if ($formHandler->processForm($form, $entity, '[entity name]')) {
    // entity valid and saved successfully, redirect
}

Retrieve validation errors/messages as an array

This is useful when passing the validation messages to JS through JSON., (*6)

$errors = FormErrors::flatten($form)

This will return an array of the errors in the format of:, (*7)

array(
    0 => array(
        'Global Error 1',
    ),
    'field_name' => array(
        'Field Error 1',
        'Field Error 2',
        ...
    ),
    ...
)

The Versions

24/10 2017

dev-master

9999999-dev https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein

24/10 2017

1.1.2

1.1.2.0 https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein

18/07 2017

1.1.1

1.1.1.0 https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein

18/07 2017

1.0.0

1.0.0.0 https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein

18/07 2017

1.1.0

1.1.0.0 https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein

06/07 2017

1.1

1.1.0.0 https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein

05/07 2017

1.0

1.0.0.0 https://github.com/xmmedia/XMFormBundle

A few helpers to make processing (creating, saving, errors, etc) forms simpler.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Darryl Hein