dev-master
9999999-dev https://github.com/Vixys/VxIpFieldTypeBundleIp form type for symfony 2 forms
MIT
The Requires
- php >=5.3.3
- symfony/framework-bundle 2.*
by SĂ©bastien Marichal
form bundle symfony ip field type symfony bundle symfony-2
Ip form type for symfony 2 forms
Provide an ip field for symfony forms., (*1)
Add VxJsUploadBundle in your composer.json:, (*2)
``` json { "require": { "vx/ip-field-bundle": "dev-master" } }, (*3)
Now you can download the bundle with composer: ``` bash $ php composer.phar update vx/ip-field-bundle
Enable the bundle in the kernel:, (*4)
``` php <?php // app/AppKernel.php, (*5)
public function registerBundles() { $bundles = array( // ... new Vx\IpFieldTypeBundle\VxIpFieldTypeBundle(), ); }, (*6)
## Usage ### Create field Create your form : ``` php $form = $this->createFormBuilder() ->add('ip', 'ipfield') ->add('send', 'submit')->getForm();
You can specify the ip version (ipv4
, ipv6
or mac
) :
``` php
->add('ip', 'ipfield', array('version' => 'ipv4')), (*7)
``` php ->add('ip', 'ipfield', array('version' => 'ipv6'))
``` php ->add('ip', 'ipfield', array('version' => 'mac')), (*8)
### View ``` html {{ 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) }}
This bundle is under the MIT Licence., (*9)
Ip form type for symfony 2 forms
MIT
form bundle symfony ip field type symfony bundle symfony-2