From 69542c311c8f4c83d7043f07c3fb7eaf86ff0d68 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 7 Mar 2015 11:02:16 +1100 Subject: [PATCH] Form field "preset" options can be a string that just specifies the other field, defaults to url type --- CHANGELOG.md | 3 +++ modules/backend/classes/FormField.php | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 905b28b99..31063e9c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* **Build 21x** (2015-03-xx) + - Form fields can now use a simpler interface for using the Input preset converter (see Backend > Forms docs). + * **Build 217** (2015-03-06) - Improvements made to the user menu in the back-end: clicking your avatar will display a popover with settings links from the `mysettings` context. - Added new form field widget called `repeater` for repeatable fields (see Backend > Forms docs). diff --git a/modules/backend/classes/FormField.php b/modules/backend/classes/FormField.php index 9b9a9d9b4..964b33553 100644 --- a/modules/backend/classes/FormField.php +++ b/modules/backend/classes/FormField.php @@ -435,9 +435,13 @@ class FormField */ protected function filterPresetAttributes($attributes, $position = 'field') { - if (!$this->preset || !is_array($this->preset) || $position != 'field') + if (!$this->preset || $position != 'field') return $attributes; + if (!is_array($this->preset)) { + $this->preset = ['field' => $this->preset, 'type' => 'slug']; + } + $presetField = array_get($this->preset, 'field'); $presetType = array_get($this->preset, 'type');