fuzzyma / contao-addresspicker
Frontend Text Field with Bootstrap Datepicker for Contao Open Source CMS
Installs: 108
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:contao-module
Requires
- php: >=5.3.2
This package is not auto-updated.
Last update: 2024-09-28 18:47:50 UTC
README
Contao Wrapper for google places autocomplete.
Comes with a widget for Backend and Frontend.
For Backend use specify addresspicker
in the dca:
$GLOBALS['TL_DCA']['tl_form_field']['fields']['componentRestrictions'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_form_field']['componentRestrictions'], 'exclude' => true, 'inputType' => 'addresspicker', 'eval' => array('category' => '(regions)', 'tl_class'=>'w50'}'), 'sql' => "varchar(255) NOT NULL default ''" );
You can pass the following options to eval:
- category: one of
geocode, address, establishment, (regions), (cities)
- componentRestrictions: a country code to restrict the picker to that country
- bounds: latitude and longitude for a rectangel the picker is restricted to: 1.223,12.421;4.23,1.213
- callback: javascipt function name or function declaration which is called when a place was selected (
somefunc
orfunction(picker){ console.log(picker.getPlace()) }
- fields you want to get filled, when a place is selected. Available fields are:
- use_route
- use_street_number
- use_locality
- use_administrative_area_level_1
- use_country
- use_postal_code
- use_lat_long
- a type to every use-field to specify
long_name
orshort_name
- use_route_type
- use_street_number_type
- use_locality_type
- use_administrative_area_level_1_type
- use_country_type
- use_postal_code_type
Make sure you have corresponding fields in your dca.
The fieldname has to be [name of the adresspicker]_[name of the field without use]
.
e.g. componentRestrictions_locality
$GLOBALS['TL_DCA']['tl_form_field']['fields']['componentRestrictions'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_form_field']['componentRestrictions'], 'exclude' => true, 'inputType' => 'addresspicker', 'eval' => array( 'callback' => 'function(a){console.log(a.getPlace())}', 'category' => '(regions)', 'tl_class' => 'w50', 'use_locality' => true, 'use_locality_type' => 'long_name' ), 'sql' => "varchar(255) NOT NULL default ''" ); // this field is filled automatically when a place is selected $GLOBALS['TL_DCA']['tl_form_field']['fields']['componentRestrictions_locality`'] = array( inputType => 'text' )