vx/ip-field-bundle

Ip form type for symfony 2 forms

dev-master 2014-02-10 09:04 UTC

This package is not auto-updated.

Last update: 2024-05-06 22:57:16 UTC


README

Provide an ip field for symfony forms.

Requirements

  • Symfony2.*

Installation

Composer

Add VxJsUploadBundle in your composer.json:

{
    "require": {
        "vx/ip-field-bundle": "dev-master"
    }
}

Now you can download the bundle with composer:

$ php composer.phar update vx/ip-field-bundle

AppKernel

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Vx\IpFieldTypeBundle\VxIpFieldTypeBundle(),
    );
}

Usage

Create field

Create your form :

$form = $this->createFormBuilder()
	->add('ip', 'ipfield')
	->add('send', 'submit')->getForm();

You can specify the ip version (ipv4, ipv6 or mac) :

	->add('ip', 'ipfield', array('version' => 'ipv4'))
	->add('ip', 'ipfield', array('version' => 'ipv6'))
	->add('ip', 'ipfield', array('version' => 'mac'))

View

{{ form_start(form) }}
    {{ form_errors(form) }}

	<div class="control-group">
		<label class="control-label" for="ip">IP</label>
		<div class="controls">
			{{ form_widget(form.ip, { 'id': 'my_ip_field', 'class': 'form-control' }) }}
		</div>
	</div>
	{{ form_rest(form) }}
{{ form_end(form) }}

Licence

This bundle is under the MIT Licence.