PHP code example of fuzzyma / contao-addresspicker

1. Go to this page and download the library: Download fuzzyma/contao-addresspicker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fuzzyma / contao-addresspicker example snippets


$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 ''"
);

$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'
)