Skip to content

Commit

Permalink
Add dynamic value field in form location list
Browse files Browse the repository at this point in the history
  • Loading branch information
Tastaturberuf committed Oct 18, 2016
1 parent 0634a8d commit 97bb586
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.9.0 Unreleased]
## [1.9.0]
###Added
- Add Google Maps API browser key support (fix #60 #61) Thanks to @DanMan
- Add possibility to login in the dynamic Google map
- Add table header customization at location list view in the backend
- Add dynamic value field in form location list

###Changed
- Sorting backend palettes
Expand Down
14 changes: 0 additions & 14 deletions config/runonce.php

This file was deleted.

31 changes: 30 additions & 1 deletion dca/tl_form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'
{type_legend},type,name,label;
{fconfig_legend},mandatory,multiple;
{options_legend},anystores_categories;
{options_legend},anystores_idField,anystores_categories;
{expert_legend:hide},class,accesskey,tabindex;
{template_legend:hide},customTpl;
{submit_legend},addSubmit
Expand All @@ -40,3 +40,32 @@
),
'sql' => "text NULL"
);

$GLOBALS['TL_DCA']['tl_form_field']['fields']['anystores_idField'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_form_field']['anystores_idField'],
'exclude' => true,
'default' => 'id',
'inputType' => 'select',
'options_callback' => function(\DataContainer $dc)
{
$arrFields = [];

System::loadLanguageFile('tl_anystores');

foreach ( $dc->Database->listFields('tl_anystores') as $arrField )
{
if ( $arrField['type'] !== 'index' )
{
$arrFields[$arrField['name']] = $GLOBALS['TL_LANG']['tl_anystores'][$arrField['name']][0] ?: $arrField['name'];
}
}

return $arrFields;
},
'eval' => array
(
'mandatory' => true
),
'sql' => "varchar(255) NOT NULL default 'id'"
);
3 changes: 2 additions & 1 deletion forms/FormStores.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct($arrAttributes = null)

$arrCategories = deserialize($this->anystores_categories);
$arrOptions = array('order'=>'postal');
$strField = $this->anystores_idField;

$objLocations = AnyStoresModel::findPublishedByCategory($arrCategories, $arrOptions);

Expand All @@ -36,7 +37,7 @@ public function __construct($arrAttributes = null)
$arrLocations[] = array
(
'type' => 'option',
'value' => $objLocations->id,
'value' => $objLocations->$strField,
'label' => $objLocations->postal.' '.$objLocations->name
);
}
Expand Down
8 changes: 7 additions & 1 deletion languages/de/tl_form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* anyStores for Contao Open Source CMS
*
* @copyright (c) 2015 Tastaturberuf <[email protected]>
* @copyright (c) 2015 - 2016 Tastaturberuf <[email protected]>
* @author Daniel Jahnsmüller <[email protected]>
* @license http://opensource.org/licenses/lgpl-3.0.html
* @package anyStores
Expand All @@ -14,3 +14,9 @@
(
'stores' => array('anyStores Liste', '')
));

array_insert($GLOBALS['TL_LANG']['tl_form_field'], 0, array
(
'anystores_idField' => array('Spalte für den Value-Wert', ''),
'anystores_categories' => array('Kategorien', '')
));
6 changes: 6 additions & 0 deletions languages/en/tl_form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
(
'stores' => array('anyStores list', '')
));

array_insert($GLOBALS['TL_LANG']['tl_form_field'], 0, array
(
'anystores_idField' => array('Column for the value', ''),
'anystores_categories' => array('Categories', '')
));

0 comments on commit 97bb586

Please sign in to comment.