mirror of
https://github.com/netzmacht/contao-leaflet-geocode-widget.git
synced 2025-11-29 12:13:40 +01:00
Support multiple option for the widget.
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Version 1.2.0 (2017-11-13)
|
||||
--------------------------
|
||||
|
||||
[Full Changelog](https://github.com/netzmacht/contao-leaflet-geocode-widget/compare/1.1.0...1.2.0)
|
||||
|
||||
- Allow multiple elements
|
||||
|
||||
Version 1.1.0
|
||||
-------------
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev",
|
||||
"dev-develop": "1.1.x-dev"
|
||||
"dev-master": "1.2.x-dev",
|
||||
"dev-develop": "1.3.x-dev"
|
||||
},
|
||||
"contao-manager-plugin": "Netzmacht\\Contao\\Leaflet\\GeocodeWidget\\ContaoManager\\Plugin"
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace Netzmacht\Contao\Leaflet\GeocodeWidget;
|
||||
/**
|
||||
* Class GeocodeWidget
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\GeocodeWidget
|
||||
* @property int size
|
||||
* @property bool multiple
|
||||
*/
|
||||
class GeocodeWidget extends \Widget
|
||||
{
|
||||
@@ -87,20 +88,39 @@ class GeocodeWidget extends \Widget
|
||||
*/
|
||||
public function generate()
|
||||
{
|
||||
$template = new \BackendTemplate($this->widgetTemplate);
|
||||
$template->setData(
|
||||
[
|
||||
'widget' => $this,
|
||||
'value' => specialchars($this->value),
|
||||
'class' => $this->strClass ? ' ' . $this->strClass : '',
|
||||
'id' => $this->strId,
|
||||
'name' => $this->strName,
|
||||
'attributes' => $this->getAttributes(),
|
||||
'wizard' => $this->wizard,
|
||||
'label' => $this->strLabel
|
||||
]
|
||||
);
|
||||
$wrapperClass = 'wizard';
|
||||
|
||||
return $template->parse();
|
||||
if (!$this->multiple || !$this->size) {
|
||||
$this->size = 1;
|
||||
} else {
|
||||
$wrapperClass .= ' wizard_' . $this->size;
|
||||
}
|
||||
|
||||
if (!is_array($this->value)) {
|
||||
$this->value = [$this->value];
|
||||
}
|
||||
|
||||
$buffer = '';
|
||||
|
||||
for ($index = 0; $index < $this->size; $index++) {
|
||||
$template = new \BackendTemplate($this->widgetTemplate);
|
||||
$template->setData(
|
||||
[
|
||||
'wrapperClass' => $wrapperClass,
|
||||
'widget' => $this,
|
||||
'value' => \StringUtil::specialchars($this->value[$index]),
|
||||
'class' => $this->strClass ? ' ' . $this->strClass : '',
|
||||
'id' => $this->strId . (($this->size > 1) ? '_' . $index : ''),
|
||||
'name' => $this->strName . (($this->size > 1) ? '[]' : ''),
|
||||
'attributes' => $this->getAttributes(),
|
||||
'wizard' => $this->wizard,
|
||||
'label' => $this->strLabel,
|
||||
]
|
||||
);
|
||||
|
||||
$buffer .= $template->parse();
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
$GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet/leaflet.css';
|
||||
$GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/control-geocoder/Control.Geocoder.css';
|
||||
$GLOBALS['TL_CSS'][] = 'bundles/leafletgeocodewidget/css/backend.css';
|
||||
|
||||
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/libs/leaflet/leaflet.js';
|
||||
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/libs/control-geocoder/Control.Geocoder.js';
|
||||
@@ -9,7 +10,7 @@ $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/leafletgeocodewidget/js/geocode.widget.js
|
||||
|
||||
?>
|
||||
|
||||
<div class="wizard">
|
||||
<div class="<?= $this->wrapperClass ?>">
|
||||
<input type="text"
|
||||
name="<?= $this->name ?>"
|
||||
id="ctrl_<?= $this->id ?>"
|
||||
|
||||
4
src/Resources/public/css/backend.css
Normal file
4
src/Resources/public/css/backend.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.wizard_2 {
|
||||
width: 325px;
|
||||
display: inline-block;
|
||||
}
|
||||
Reference in New Issue
Block a user