1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| <?php
namespace Test\TestBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Test\TestBundle\Entity\Client;
use Test\TestBundle\Form\ClientType;
class DefaultController extends Controller
{
public function indexAction($name)
{
$client = new Client;
$form = $this->createForm(new ClientType(), $client);
return $this->render('TestTestBundle:Default:index.html.twig', array('name' => $name,
'form' => $form->createView(),));
}
}
et ci-dessous le code de mon template
{% block stylesheets %}
<link href="{{ asset('css/jquery-ui-1.8.16.custom.css') }}" rel="stylesheet" />
<link href="{{ asset('css/uploadify.css') }}" rel="stylesheet" />
<link href="{{ asset('css/jquery.Jcrop.css') }}" rel="stylesheet" />
<link href="{{ asset('css/token-input-facebook.css') }}" rel="stylesheet" />
<link href="{{ asset('css/select2.css') }}" rel="stylesheet" />
{{ form_stylesheet(form) }}
{% endblock %}
{% block javascripts %}
<script src="{{ asset('js/jquery-1.4.4.min.js') }}"></script>
<script src="{{ asset('js/jquery-ui-1.8.7.min.js') }}"></script>
<script src="{{ asset('js/tinymce.js') }}"></script>
<script src="{{ asset('js/jquery-ui-i18n.js') }}"></script>
<script src="{{ asset('js/jquery.uploadify.min.js') }}"></script>
<script src="{{ asset('js/select2.min.js') }}"></script>
<script src="{{ asset('js/jquery.ui.ardresspicker.js') }}"></script>
<script src="{{ asset('http://maps.google.com/maps/api/js?sensor=false') }}"></script>
<script src="{{ asset('js/jquery.Jcrop.min.js') }}"></script>
<script src="{{ asset('js/jquery/jquery.tokeninput.js') }}"></script> <!-- You have to apply the fix <a href="https://github.com/loopj/jquery-tokeninput/pull/172/files" target="_blank">https://github.com/loopj/jquery-toke...pull/172/files</a> for tokeninput to get it work!! -->
<script >
$(function() {
var addresspicker = $( "#addresspicker" ).addresspicker();
var addresspickerMap = $( "#addresspicker_map" ).addresspicker({
regionBias: "fr",
updateCallback: showCallback,
elements: {
map: "#map",
lat: "#lat",
lng: "#lng",
street_number: '#street_number',
route: '#route',
locality: '#locality',
administrative_area_level_2: '#administrative_area_level_2',
administrative_area_level_1: '#administrative_area_level_1',
country: '#country',
postal_code: '#postal_code',
type: '#type'
}
});
var gmarker = addresspickerMap.addresspicker( "marker");
gmarker.setVisible(true);
addresspickerMap.addresspicker( "updatePosition");
$('#reverseGeocode').change(function(){
$("#addresspicker_map").addresspicker("option", "reverseGeocode", ($(this).val() === 'true'));
});
function showCallback(geocodeResult, parsedGeocodeResult){
$('#callback_result').text(JSON.stringify(parsedGeocodeResult, null, 4));
}
});
</script>
{{ form_javascript(form) }}
{% endblock %}
{% block body %}
<form type="post" {{ form_enctype(form) }}>
{{ form_widget(form) }}
<input type="submit" />
</form>
{% endblock %}
ci dessous le code du formulaire que j'ai testé pour adresspicker
<?php
namespace Test\TestBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class ClientType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('nom')
->add('categorie')
->add('pays','genemu_jquerygeolocation')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Test\TestBundle\Entity\Client'
));
}
public function getName()
{
return 'test_testbundle_clienttype';
}
} |
Partager