Skip to content

Commit 2db5501

Browse files
committed
prepare 3.9.0, small adjustments to alias field
1 parent f2d3831 commit 2db5501

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [3.8.0] - 2025-05-20
6-
Added: StaticArrayUtils::filterByPrefixes
5+
## [3.9.0] - 2025-05-20
6+
- Added: StaticArrayUtils::filterByPrefixes ([#100](https://github.com/heimrichhannot/contao-utils-bundle/pull/100))
7+
- Added: AliasField ([#102](https://github.com/heimrichhannot/contao-utils-bundle/pull/102))
8+
9+
## [3.8.0] - 2025-04-14
10+
- Changed: Url Util Improvements by @ericges in https://github.com/heimrichhannot/contao-utils-bundle/pull/94
11+
- Fixed: EntityFinderHelper.php by @ericges in https://github.com/heimrichhannot/contao-utils-bundle/pull/95
712

813
## [3.7.1] - 2025-03-20
914
- Changed: enhance code quality by using rector

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,32 @@ DateAddedField::register('tl_example')
143143
;
144144
```
145145

146+
#### Alias field
147+
148+
Add an alias field to your dca. Set the alias if the alias field is empty on save and check for duplicates.
149+
150+
```php
151+
use HeimrichHannot\UtilsBundle\Dca\AliasField;
152+
153+
AliasField::register('tl_example');
154+
```
155+
156+
You can pass additional options to adjust the field:
157+
```php
158+
# contao/dca/tl_example.php
159+
use HeimrichHannot\UtilsBundle\Dca\AliasField;
160+
161+
AliasField::register('tl_example')
162+
AliasField::register('tl_md_newsletter')
163+
->setAliasExistCallback([NewsletterCallbackListener::class, 'checkAliasExist']) // set a custom alias exist callback
164+
->setExclude(false) // set the dca field exclude option
165+
->setSearch(false) // set the dca field search option
166+
->setFilter(false) // set the dca field filter option
167+
->setSorting(true) // set the dca field sorting option
168+
->setFlag(null) // set the dca field flag option
169+
;
170+
```
171+
146172
### Entity Finder
147173

148174
The entity finder is a command to search for any contao entities in your database.

src/Dca/AliasField.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ class AliasField extends AbstractDcaField
66
{
77
private static $tables = [];
88

9+
/**
10+
* @return AliasFieldConfiguration
11+
*/
12+
public static function register(string $table): DcaFieldConfiguration
13+
{
14+
return parent::register($table);
15+
}
16+
917
protected static function storeConfig(DcaFieldConfiguration $config): void
1018
{
1119
self::$tables[$config->getTable()] = $config;
@@ -27,7 +35,13 @@ public static function getField(): array
2735
'exclude' => true,
2836
'search' => true,
2937
'inputType' => 'text',
30-
'eval' => ['rgxp' => 'alias', 'unique' => true, 'maxlength' => 128, 'tl_class' => 'w50'],
38+
'eval' => [
39+
'rgxp' => 'alias',
40+
'unique' => true,
41+
'maxlength' => 128,
42+
'tl_class' => 'w50',
43+
'doNotCopy'=>true,
44+
],
3145
'save_callback' => [],
3246
'sql' => "varchar(255) BINARY NOT NULL default ''",
3347
];

0 commit comments

Comments
 (0)