Repository: CSCfi/rems
Pull request #1398 (2019-07-11 13:03:03)

Field schema unification
Part of #913. Unifies the read and write models for form fields.


Patch:
diff --git a/resources/migrations/20190711111351-refactor-form-templates.edn b/resources/migrations/20190711111351-refactor-form-templates.edn
new file mode 100644
index 000000000..eb05ca595
--- /dev/null
+++ b/resources/migrations/20190711111351-refactor-form-templates.edn
@@ -0,0 +1,3 @@
+{:ns rems.migrations.refactor-form-templates
+ :up-fn migrate-up
+ :down-fn nil}
diff --git a/resources/translations/en.edn b/resources/translations/en.edn
index 1531eceb3..0d3dff16b 100644
--- a/resources/translations/en.edn
+++ b/resources/translations/en.edn
@@ -168,12 +168,12 @@
                 :add-option "Add option"
                 :field-n "Field %1"
                 :field-title "Field title"
-                :input-prompt "Placeholder text (optional)"
                 :maxlength "Maximum length (optional)"
                 :option-key "ID code"
                 :option-label "Label"
                 :option-n "Option %1"
                 :optional "Optional"
+                :placeholder "Placeholder text (optional)"
                 :title "Form name"
                 :type-attachment "Attachment"
                 :type-date "Date field"
diff --git a/resources/translations/fi.edn b/resources/translations/fi.edn
index 1b4fd772f..b81289969 100644
--- a/resources/translations/fi.edn
+++ b/resources/translations/fi.edn
@@ -168,12 +168,12 @@
                 :add-option "Lisää vaihtoehto"
                 :field-n "Kenttä %1"
                 :field-title "Kentän otsikko"
-                :input-prompt "Esimerkkiteksti (ei pakollinen)"
                 :maxlength "Enimmäispituus (ei pakollinen)"
                 :option-key "Tunniste"
                 :option-label "Otsikko"
                 :option-n "Vaihtoehto %1"
                 :optional "Ei pakollinen"
+                :placeholder "Esimerkkiteksti (ei pakollinen)"
                 :title "Lomakkeen nimi"
                 :type-attachment "Liitetiedosto"
                 :type-date "Päivämäärä"
diff --git a/src/clj/rems/api/forms.clj b/src/clj/rems/api/forms.clj
index 9161c57b3..23fbd6e28 100644
--- a/src/clj/rems/api/forms.clj
+++ b/src/clj/rems/api/forms.clj
@@ -1,69 +1,25 @@
 (ns rems.api.forms
   (:require [compojure.api.sweet :refer :all]
-            [rems.api.schema :refer [SuccessResponse UpdateStateCommand]]
-            [rems.api.util]
+            [rems.api.schema :refer [SuccessResponse UpdateStateCommand FormTemplateOverview NewFieldTemplate FormTemplate]]
+            [rems.api.util :refer [not-found-json-response]]
             [rems.db.form :as form]
             [rems.util :refer [getx-user-id]]
             [ring.util.http-response :refer :all]
-            [schema.core :as s])
-  (:import (org.joda.time DateTime)))
-
-(s/defschema Form
-  {:id s/Num
-   :organization s/Str
-   :title s/Str
-   :start DateTime
-   :end (s/maybe DateTime)
-   :expired s/Bool
-   :enabled s/Bool
-   :archived s/Bool})
-
-(def not-neg? (partial <= 0))
-
-(s/defschema FormField
-  {:title {s/Keyword s/Str}
-   :optional s/Bool
-   :type (s/enum "attachment" "date" "description" "label" "multiselect" "option" "text" "texta")
-   (s/optional-key :maxlength) (s/maybe (s/constrained s/Int not-neg?))
-   (s/optional-key :options) [{:key s/Str
-                               :label {s/Keyword s/Str}}]
-   (s/optional-key :input-prompt) {s/Keyword s/Str}})
-
-(s/defschema FormFieldWithId
-  (merge FormField
-         {:id s/Int}))
-
-(s/defschema FullForm
-  (merge Form
-         {:fields [FormFieldWithId]}))
-
-(s/defschema Forms
-  [Form])
-
-(defn- format-form
-  [{:keys [id organization title start end expired enabled archived]}]
-  {:id id
-   :organization organization
-   :title title
-   :start start
-   :end end
-   :expired expired
-   :enabled enabled
-   :archived archived})
+            [schema.core :as s]))
 
 (defn- get-form-templates [filters]
   (doall
-   (for [wf (form/get-form-templates filters)]
-     (format-form wf))))
+   (for [form (form/get-form-templates filters)]
+     (select-keys form [:id :organization :title :start :end :expired :enabled :archived]))))
 
 (s/defschema FormCommand
   {:organization s/Str
    :title s/Str
-   :fields [FormField]})
+   :fields [NewFieldTemplate]})
 
 (s/defschema FormResponse
   {:success s/Bool
-   :id s/Num})
+   :id s/Int})
 
 (def forms-api
   (context "/forms" []
@@ -75,7 +31,7 @@
       :query-params [{disabled :- (describe s/Bool "whether to include disabled forms") false}
                      {expired :- (describe s/Bool "whether to include expired forms") false}
                      {archived :- (describe s/Bool "whether to include archived forms") false}]
-      :return Forms
+      :return [FormTemplateOverview]
       (ok (get-form-templates (merge (when-not expired {:expired false})
                                      (when-not disabled {:enabled true})
                                      (when-not archived {:archived false})))))
@@ -90,9 +46,12 @@
     (GET "/:form-id" []
       :summary "Get form by id"
       :roles #{:owner}
-      :path-params [form-id :- (describe s/Num "form-id")]
-      :return FullForm
-      (ok (form/get-form-template form-id)))
+      :path-params [form-id :- (describe s/Int "form-id")]
+      :return FormTemplate
+      (let [form (form/get-form-template form-id)]
+        (if form
+          (ok form)
+          (not-found-json-response))))
 
     (GET "/:form-id/editable" []
       :summary "Check if the form is editable"
diff --git a/src/clj/rems/api/schema.clj b/src/clj/rems/api/schema.clj
index 9f616f40d..61e8f418a 100644
--- a/src/clj/rems/api/schema.clj
+++ b/src/clj/rems/api/schema.clj
@@ -108,17 +108,39 @@
    :license/expired s/Bool
    :license/archived s/Bool})
 
-(s/defschema Field
+(def not-neg? (partial <= 0))
+
+(s/defschema FieldTemplate
   {:field/id s/Int
-   :field/value s/Str
-   (s/optional-key :field/previous-value) s/Str
    :field/type (s/enum :attachment :date :description :label :multiselect :option :text :texta)
    :field/title LocalizedString
-   :field/placeholder LocalizedString
+   (s/optional-key :field/placeholder) LocalizedString
    :field/optional s/Bool
-   :field/options [{:key s/Str
-                    :label LocalizedString}]
-   :field/max-length (s/maybe s/Int)})
+   (s/optional-key :field/options) [{:key s/Str
+                                     :label LocalizedString}]
+   (s/optional-key :field/max-length) (s/maybe (s/constrained s/Int not-neg?))})
+
+(s/defschema NewFieldTemplate
+  (dissoc FieldTemplate :field/id))
+
+(s/defschema Field
+  (assoc FieldTemplate
+         :field/value s/Str
+         (s/optional-key :field/previous-value) s/Str))
+
+(s/defschema FormTemplate ; TODO: use prefixed keys
+  {:id s/Int
+   :organization s/Str
+   :title s/Str
+   :fields [FieldTemplate]
+   :start DateTime
+   :end (s/maybe DateTime)
+   :expired s/Bool
+   :enabled s/Bool
+   :archived s/Bool})
+
+(s/defschema FormTemplateOverview
+  (dissoc FormTemplate :fields))
 
 (s/defschema Form
   {:form/id s/Int
diff --git a/src/clj/rems/application/model.clj b/src/clj/rems/application/model.clj
index 4fdcbe762..5e729fdc5 100644
--- a/src/clj/rems/application/model.clj
+++ b/src/clj/rems/application/model.clj
@@ -420,22 +420,15 @@
          (localization-for :title {:localizations {:en {}
                                                    :fi {}}}))))
 
-(defn- enrich-form [app-form get-form-template]
-  (let [form (get-form-template (:form/id app-form))
-        app-fields (:form/fields app-form)
-        rich-fields (map (fn [field]
-                           {:field/id (:id field)
-                            :field/value "" ; default for new forms
-                            :field/type (keyword (:type field))
-                            :field/title (:title field)
-                            :field/placeholder (get field :input-prompt {})
-                            :field/optional (:optional field)
-                            :field/options (:options field)
-                            :field/max-length (:maxlength field)})
-                         (:fields form))
-        fields (merge-lists-by :field/id rich-fields app-fields)]
-    (assoc app-form
-           :form/title (:title form)
+(defn- enrich-form [form get-form-template]
+  (let [form-template (get-form-template (:form/id form))
+        default-fields (map #(assoc % :field/value "")
+                            (:fields form-template))
+        fields (merge-lists-by :field/id
+                               default-fields
+                               (:form/fields form))]
+    (assoc form
+           :form/title (:title form-template)
            :form/fields fields)))
 
 (defn- set-application-description [application]
diff --git a/src/clj/rems/db/form.clj b/src/clj/rems/db/form.clj
index 78397584f..cccef050d 100644
--- a/src/clj/rems/db/form.clj
+++ b/src/clj/rems/db/form.clj
@@ -1,14 +1,24 @@
 (ns rems.db.form
   (:require [clojure.test :refer :all]
+            [rems.api.schema :refer [FieldTemplate]]
             [rems.db.catalogue :as catalogue]
             [rems.db.core :as db]
-            [rems.json :as json]))
+            [rems.json :as json]
+            [schema.coerce :as coerce]
+            [schema.core :as s]))
 
-;;; form api related code – form "templates"
+(def ^:private fields-coercer
+  (coerce/coercer [FieldTemplate] coerce/string-coercion-matcher))
+
+(defn- coerce-fields [fields]
+  (let [result (fields-coercer fields)]
+    (if (schema.utils/error? result)
+      (throw (ex-info "Failed to coerce fields" {:fields fields :error result}))
+      result)))
 
 (defn- parse-db-row [row]
   (-> row
-      (update :fields json/parse-string)
+      (update :fields #(coerce-fields (json/parse-string %)))
       db/assoc-expired))
 
 (defn get-form-templates [filters]
@@ -17,11 +27,12 @@
        (db/apply-filters filters)))
 
 (defn get-form-template [id]
-  (-> (db/get-form-template {:id id})
-      parse-db-row))
+  (let [row (db/get-form-template {:id id})]
+    (when row
+      (parse-db-row row))))
 
-(defn- create-form-item! [user-id form-id item-index {:keys [title optional type input-prompt maxlength options]}]
-  (let [item-id (:id (db/create-form-item! {:type type
+(defn- create-form-item! [user-id form-id item-index {:field/keys [title optional type max-length options placeholder]}]
+  (let [item-id (:id (db/create-form-item! {:type (name type)
                                             :user user-id
                                             :value 0}))]
     (doseq [[index option] (map-indexed vector options)]
@@ -34,14 +45,14 @@
     (db/link-form-item! {:form form-id
                          :itemorder item-index
                          :optional optional
-                         :maxlength maxlength
+                         :maxlength max-length
                          :item item-id
                          :user user-id})
     (doseq [lang (keys title)]
       (db/localize-form-item! {:item item-id
                                :langcode (name lang)
                                :title (get title lang)
-                               :inputprompt (get input-prompt lang)}))
+                               :inputprompt (get placeholder lang)}))
     item-id))
 
 (defn- catalogue-items-for-form [id]
@@ -65,7 +76,7 @@
   ;; order, or generate UUIDs)
   (map-indexed (fn [order field]
                  (let [id (create-form-item! user-id form-id order field)]
-                   (assoc field :id id)))
+                   (assoc field :field/id id)))
                fields))
 
 (defn create-form! [user-id {:keys [organization title fields] :as form}]
@@ -76,13 +87,14 @@
         ;;   codepath will be removed soon.
         form-id (:id (db/create-form! {:organization organization
                                        :title title
-                                       :user user-id}))
-        fields-with-ids (generate-fields-with-ids! user-id form-id fields)]
+                                       :user user-id}))]
     (db/save-form-template!
      (assoc form
             :id form-id
             :user user-id
-            :fields (json/generate-string fields-with-ids)))
+            :fields (->> (generate-fields-with-ids! user-id form-id fields)
+                         (s/validate [FieldTemplate])
+                         (json/generate-string))))
     {:success (not (nil? form-id))
      :id form-id}))
 
@@ -92,7 +104,9 @@
            (assoc form
                   :id form-id
                   :user user-id
-                  :fields (json/generate-string (generate-fields-with-ids! user-id form-id fields))))
+                  :fields (->> (generate-fields-with-ids! user-id form-id fields)
+                               (s/validate [FieldTemplate])
+                               (json/generate-string))))
           {:success true})))
 
 (defn update-form! [command]
diff --git a/src/clj/rems/migrations/refactor_form_templates.clj b/src/clj/rems/migrations/refactor_form_templates.clj
new file mode 100644
index 000000000..32644656b
--- /dev/null
+++ b/src/clj/rems/migrations/refactor_form_templates.clj
@@ -0,0 +1,36 @@
+(ns rems.migrations.refactor-form-templates
+  (:require [hugsql.core :as hugsql]
+            [medley.core :refer [map-keys]]
+            [rems.json :as json]))
+
+(hugsql/def-db-fns-from-string
+ "
+-- :name get-form-templates :? :*
+SELECT
+ id,
+ fields::TEXT
+FROM form_template;
+
+-- :name update-form-template! :!
+UPDATE form_template
+SET fields = :fields::jsonb
+WHERE id = :id;
+")
+
+(defn- migrate-field [field]
+  (map-keys {:id :field/id
+             :type :field/type
+             :title :field/title
+             :input-prompt :field/placeholder
+             :optional :field/optional
+             :options :field/options
+             :maxlength :field/max-length}
+            field))
+
+(defn migrate-up [{:keys [conn]}]
+  (doseq [{:keys [id fields]} (get-form-templates conn)]
+    (update-form-template! conn {:id id
+                                 :fields (->> fields
+                                              json/parse-string
+                                              (map migrate-field)
+                                              json/generate-string)})))
diff --git a/src/clj/rems/validate.clj b/src/clj/rems/validate.clj
index 1cdc0a8da..4ec221694 100644
--- a/src/clj/rems/validate.clj
+++ b/src/clj/rems/validate.clj
@@ -9,7 +9,7 @@
 
 (defn validate-forms []
   (doseq [template (form/get-form-templates {})]
-    (s/validate rems.api.forms/FullForm template)))
+    (s/validate rems.api.schema/FormTemplate template)))
 
 (defn validate []
   (log/info "Validating data")
diff --git a/src/cljs/rems/administration/create_form.cljs b/src/cljs/rems/administration/create_form.cljs
index 4a927e5d2..034e9a98e 100644
--- a/src/cljs/rems/administration/create_form.cljs
+++ b/src/cljs/rems/administration/create_form.cljs
@@ -47,7 +47,7 @@
 (rf/reg-sub ::edit-form? (fn [db _] (::edit-form? db)))
 (rf/reg-event-db ::set-form-field (fn [db [_ keys value]] (assoc-in db (concat [::form] keys) value)))
 
-(rf/reg-event-db ::add-form-field (fn [db [_]] (update-in db [::form :fields] items/add {:type "text"})))
+(rf/reg-event-db ::add-form-field (fn [db [_]] (update-in db [::form :fields] items/add {:field/type :text})))
 (rf/reg-event-db ::remove-form-field (fn [db [_ field-index]] (update-in db [::form :fields] items/remove field-index)))
 (rf/reg-event-db ::move-form-field-up (fn [db [_ field-index]] (update-in db [::form :fields] items/move-up field-index)))
 (rf/reg-event-db ::move-form-field-down (fn [db [_ field-index]] (update-in db [::form :fields] items/move-down field-index)))
@@ -55,55 +55,55 @@
 (rf/reg-event-db
  ::add-form-field-option
  (fn [db [_ field-index]]
-   (update-in db [::form :fields field-index :options] items/add {})))
+   (update-in db [::form :fields field-index :field/options] items/add {})))
 
 (rf/reg-event-db
  ::remove-form-field-option
  (fn [db [_ field-index option-index]]
-   (update-in db [::form :fields field-index :options] items/remove option-index)))
+   (update-in db [::form :fields field-index :field/options] items/remove option-index)))
 
 (rf/reg-event-db
  ::move-form-field-option-up
  (fn [db [_ field-index option-index]]
-   (update-in db [::form :fields field-index :options] items/move-up option-index)))
+   (update-in db [::form :fields field-index :field/options] items/move-up option-index)))
 
 (rf/reg-event-db
  ::move-form-field-option-down
  (fn [db [_ field-index option-index]]
-   (update-in db [::form :fields field-index :options] items/move-down option-index)))
+   (update-in db [::form :fields field-index :field/options] items/move-down option-index)))
 
 ;;;; form submit
 
 (defn- supports-optional? [field]
-  (not= "label" (:type field)))
+  (not= :label (:field/type field)))
 
-(defn- supports-input-prompt? [field]
-  (contains? #{"text" "texta" "description"} (:type field)))
+(defn- supports-placeholder? [field]
+  (contains? #{:text :texta :description} (:field/type field)))
 
-(defn- supports-maxlength? [field]
-  (contains? #{"text" "texta"} (:type field)))
+(defn- supports-max-length? [field]
+  (contains? #{:text :texta} (:field/type field)))
 
 (defn- supports-options? [field]
-  (contains? #{"option" "multiselect"} (:type field)))
+  (contains? #{:option :multiselect} (:field/type field)))
 
 (defn build-localized-string [lstr languages]
   (into {} (for [language languages]
              [language (get lstr language "")])))
 
 (defn- build-request-field [field languages]
-  (merge {:title (build-localized-string (:title field) languages)
-          :type (:type field)
-          :optional (if (supports-optional? field)
-                      (boolean (:optional field))
-                      false)}
-         (when (supports-input-prompt? field)
-           {:input-prompt (build-localized-string (:input-prompt field) languages)})
-         (when (supports-maxlength? field)
-           {:maxlength (parse-int (:maxlength field))})
+  (merge {:field/title (build-localized-string (:field/title field) languages)
+          :field/type (:field/type field)
+          :field/optional (if (supports-optional? field)
+                            (boolean (:field/optional field))
+                            false)}
+         (when (supports-placeholder? field)
+           {:field/placeholder (build-localized-string (:field/placeholder field) languages)})
+         (when (supports-max-length? field)
+           {:field/max-length (parse-int (:field/max-length field))})
          (when (supports-options? field)
-           {:options (for [{:keys [key label]} (:options field)]
-                       {:key key
-                        :label (build-localized-string label languages)})})))
+           {:field/options (for [{:keys [key label]} (:field/options field)]
+                             {:key key
+                              :label (build-localized-string label languages)})})))
 
 (defn build-request [form languages]
   {:organization (:organization form)
@@ -125,28 +125,28 @@
     (when (not-empty (remove identity validated))
       {key (apply merge validated)})))
 
-(def ^:private maxlength-range [0 32767])
+(def ^:private max-length-range [0 32767])
 
-(defn- validate-maxlength [maxlength]
-  (when-not (str/blank? maxlength)
-    (let [parsed (parse-int maxlength)]
+(defn- validate-max-length [max-length]
+  (when-not (str/blank? max-length)
+    (let [parsed (parse-int max-length)]
       (when (or (nil? parsed)
-                (not (<= (first maxlength-range) parsed (second maxlength-range))))
-        {:maxlength :t.form.validation/invalid-value}))))
+                (not (<= (first max-length-range) parsed (second max-length-range))))
+        {:field/max-length :t.form.validation/invalid-value}))))
 
 (defn- validate-option [option id languages]
   {id (merge (validate-text-field option :key)
              (validate-localized-text-field option :label languages))})
 
 (defn- validate-options [options languages]
-  {:options (apply merge (mapv #(validate-option %1 %2 languages) options (range)))})
+  {:field/options (apply merge (mapv #(validate-option %1 %2 languages) options (range)))})
 
 (defn- validate-field [field id languages]
-  {id (merge (validate-text-field field :type)
-             (validate-localized-text-field field :title languages)
-             (validate-optional-localized-field field :input-prompt languages)
-             (validate-maxlength (:maxlength field))
-             (validate-options (:options field) languages))})
+  {id (merge (validate-text-field field :field/type)
+             (validate-localized-text-field field :field/title languages)
+             (validate-optional-localized-field field :field/placeholder languages)
+             (validate-max-length (:field/max-length field))
+             (validate-options (:field/options field) languages))})
 
 (defn validate-form [form languages]
   (-> (merge (validate-text-field form :organization)
@@ -174,7 +174,7 @@
                   {:params (build-request (db ::form) (db :languages))
                    :handler (partial status-modal/common-success-handler! #(dispatch! (str "#/administration/forms/" (or (db ::form-id) (:id %)))))
                    :error-handler status-modal/common-error-handler!})
-      {:db (assoc db ::form-errors form-errors)}))))
+       {:db (assoc db ::form-errors form-errors)}))))
 
 ;;;; UI
 
@@ -193,15 +193,15 @@
                        :label (text :t.create-form/title)}])
 
 (defn- form-field-title-field [field-index]
-  [localized-text-field context {:keys [:fields field-index :title]
+  [localized-text-field context {:keys [:fields field-index :field/title]
                                  :label (text :t.create-form/field-title)}])
 
-(defn- form-field-input-prompt-field [field-index]
-  [localized-text-field context {:keys [:fields field-index :input-prompt]
-                                 :label (text :t.create-form/input-prompt)}])
+(defn- form-field-placeholder-field [field-index]
+  [localized-text-field context {:keys [:fields field-index :field/placeholder]
+                                 :label (text :t.create-form/placeholder)}])
 
-(defn- form-field-maxlength-field [field-index]
-  [text-field context {:keys [:fields field-index :maxlength]
+(defn- form-field-max-length-field [field-index]
+  [text-field context {:keys [:fields field-index :field/max-length]
                        :label (text :t.create-form/maxlength)}])
 
 (defn- add-form-field-option-button [field-index]
@@ -228,35 +228,35 @@
      [move-form-field-option-up-button field-index option-index]
      [move-form-field-option-down-button field-index option-index]
      [remove-form-field-option-button field-index option-index]]]
-   [text-field context {:keys [:fields field-index :options option-index :key]
+   [text-field context {:keys [:fields field-index :field/options option-index :key]
                         :label (text :t.create-form/option-key)
                         :normalizer normalize-option-key}]
-   [localized-text-field context {:keys [:fields field-index :options option-index :label]
+   [localized-text-field context {:keys [:fields field-index :field/options option-index :label]
                                   :label (text :t.create-form/option-label)}]])
 
 (defn- form-field-option-fields [field-index]
   (let [form @(rf/subscribe [::form])]
     (into (into [:div]
-                (for [option-index (range (count (get-in form [:fields field-index :options])))]
+                (for [option-index (range (count (get-in form [:fields field-index :field/options])))]
                   [form-field-option-field field-index option-index]))
           [[:div.form-field-option.new-form-field-option
             [add-form-field-option-button field-index]]])))
 
 (defn- form-field-type-radio-group [field-index]
   [radio-button-group context {:id (str "radio-group-" field-index)
-                               :keys [:fields field-index :type]
+                               :keys [:fields field-index :field/type]
                                :orientation :vertical
-                               :options [{:value "text", :label (text :t.create-form/type-text)}
-                                         {:value "texta", :label (text :t.create-form/type-texta)}
-                                         {:value "description", :label (text :t.create-form/type-description)}
-                                         {:value "option", :label (text :t.create-form/type-option)}
-                                         {:value "multiselect", :label (text :t.create-form/type-multiselect)}
-                                         {:value "date", :label (text :t.create-form/type-date)}
-                                         {:value "attachment", :label (text :t.create-form/type-attachment)}
-                                         {:value "label", :label (text :t.create-form/type-label)}]}])
+                               :options [{:value :text, :label (text :t.create-form/type-text)}
+                                         {:value :texta, :label (text :t.create-form/type-texta)}
+                                         {:value :description, :label (text :t.create-form/type-description)}
+                                         {:value :option, :label (text :t.create-form/type-option)}
+                                         {:value :multiselect, :label (text :t.create-form/type-multiselect)}
+                                         {:value :date, :label (text :t.create-form/type-date)}
+                                         {:value :attachment, :label (text :t.create-form/type-attachment)}
+                                         {:value :label, :label (text :t.create-form/type-label)}]}])
 
 (defn- form-field-optional-checkbox [field-index]
-  [checkbox context {:keys [:fields field-index :optional]
+  [checkbox context {:keys [:fields field-index :field/optional]
                      :label (text :t.create-form/optional)}])
 
 (defn- add-form-field-button []
@@ -302,10 +302,10 @@
                         [form-field-type-radio-group field-index]
                         (when (supports-optional? field)
                           [form-field-optional-checkbox field-index])
-                        (when (supports-input-prompt? field)
-                          [form-field-input-prompt-field field-index])
-                        (when (supports-maxlength? field)
-                          [form-field-maxlength-field field-index])
+                        (when (supports-placeholder? field)
+                          [form-field-placeholder-field field-index])
+                        (when (supports-max-length? field)
+                          [form-field-max-length-field field-index])
                         (when (supports-options? field)
                           [form-field-option-fields field-index])])
                      fields)))
@@ -313,16 +313,16 @@
 (defn- form-field-to-application-field
   "Convert a field from the form create model to the application view model."
   [field]
-  (merge {:field/type (keyword (:type field))
-          :field/title (:title field)}
+  (merge {:field/type (:field/type field)
+          :field/title (:field/title field)}
          (when (supports-optional? field)
-           {:field/optional (:optional field)})
-         (when (supports-input-prompt? field)
-           {:field/placeholder (:input-prompt field)})
-         (when (supports-maxlength? field)
-           {:field/max-length (parse-int (:maxlength field))})
+           {:field/optional (:field/optional field)})
+         (when (supports-placeholder? field)
+           {:field/placeholder (:field/placeholder field)})
+         (when (supports-max-length? field)
+           {:field/max-length (parse-int (:field/max-length field))})
          (when (supports-options? field)
-           {:field/options (:options field)})))
+           {:field/options (:field/options field)})))
 
 (defn- field-preview [field]
   [fields/field (form-field-to-application-field field)])
diff --git a/src/cljs/rems/administration/status_flags.cljs b/src/cljs/rems/administration/status_flags.cljs
index 3aa842f65..e2a0ed3bd 100644
--- a/src/cljs/rems/administration/status_flags.cljs
+++ b/src/cljs/rems/administration/status_flags.cljs
@@ -50,7 +50,8 @@
 
 (defn- format-update-error [{:keys [type catalogue-items resources workflows]}]
   (let [language @(rf/subscribe [:language])]
-    [:p (text type)
+    [:<>
+     [:p (text type)]
      (into [:ul]
            (for [ci catalogue-items]
              ;; TODO open in new tab?
diff --git a/src/cljs/rems/application.cljs b/src/cljs/rems/application.cljs
index 61f61ea27..3ad47d0bc 100644
--- a/src/cljs/rems/application.cljs
+++ b/src/cljs/rems/application.cljs
@@ -731,7 +731,7 @@
               :application/form {:form/fields [{:field/id 1
                                                 :field/type :text
                                                 :field/title {:en "Field 1"}
-                                                :field/placeholder {:en "prompt 1"}}
+                                                :field/placeholder {:en "placeholder 1"}}
                                                {:field/id 2
                                                 :field/type :label
                                                 :title "Please input your wishes below."}
@@ -739,11 +739,11 @@
                                                 :field/type :texta
                                                 :field/optional true
                                                 :field/title {:en "Field 2"}
-                                                :field/placeholder {:en "prompt 2"}}
+                                                :field/placeholder {:en "placeholder 2"}}
                                                {:field/id 4
                                                 :field/type :unsupported
                                                 :field/title {:en "Field 3"}
-                                                :field/placeholder {:en "prompt 3"}}
+                                                :field/placeholder {:en "placeholder 3"}}
                                                {:field/id 5
                                                 :field/type :date
                                                 :field/title {:en "Field 4"}}]}
@@ -767,7 +767,7 @@
               :application/form {:form/fields [{:field/id 1
                                                 :field/type :text
                                                 :field/title {:en "Field 1"}
-                                                :field/placeholder {:en "prompt 1"}}]}
+                                                :field/placeholder {:en "placeholder 1"}}]}
               :application/licenses [{:license/id 4
                                       :license/type :text
                                       :license/title {:en "A Text License"}
@@ -785,7 +785,7 @@
               :application/form {:form/fields [{:field/id 1
                                                 :field/type :text
                                                 :field/title {:en "Field 1"}
-                                                :field/placeholder {:en "prompt 1"}}]}
+                                                :field/placeholder {:en "placeholder 1"}}]}
               :application/licenses [{:license/id 4
                                       :license/type :text
                                       :license/title {:en "A Text License"}
diff --git a/src/cljs/rems/fields.cljs b/src/cljs/rems/fields.cljs
index 405bec6e9..7fe03f0a4 100644
--- a/src/cljs/rems/fields.cljs
+++ b/src/cljs/rems/fields.cljs
@@ -289,54 +289,54 @@
             [:form
              [field {:field/type :text
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}}]])
+                     :field/placeholder {:en "placeholder"}}]])
    (example "field of type \"text\" with maximum length"
             [:form
              [field {:field/type :text
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :field/max-length 10}]])
    (example "field of type \"text\" with validation error"
             [:form
              [field {:field/type :text
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :validation {:type :t.form.validation/required}}]])
    (example "non-editable field of type \"text\" without text"
             [:form
              [field {:field/type :text
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :readonly true}]])
    (example "non-editable field of type \"text\" with text"
             [:form
              [field {:field/type :text
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :readonly true
                      :field/value lipsum-short}]])
    (example "field of type \"texta\""
             [:form
              [field {:field/type :texta
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}}]])
+                     :field/placeholder {:en "placeholder"}}]])
    (example "field of type \"texta\" with maximum length"
             [:form
              [field {:field/type :texta
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :field/max-length 10}]])
    (example "field of type \"texta\" with validation error"
             [:form
              [field {:field/type :texta
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :validation {:type :t.form.validation/required}}]])
    (example "non-editable field of type \"texta\""
             [:form
              [field {:field/type :texta
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}
+                     :field/placeholder {:en "placeholder"}
                      :readonly true
                      :field/value lipsum-paragraphs}]])
    (let [previous-lipsum-paragraphs (-> lipsum-paragraphs
@@ -347,14 +347,14 @@
                [:form
                 [field {:field/type :texta
                         :field/title {:en "Title"}
-                        :field/placeholder {:en "prompt"}
+                        :field/placeholder {:en "placeholder"}
                         :field/value lipsum-paragraphs
                         :field/previous-value previous-lipsum-paragraphs}]])
       (example "editable field of type \"texta\" with previous value, diff shown"
                [:form
                 [field {:field/type :texta
                         :field/title {:en "Title"}
-                        :field/placeholder {:en "prompt"}
+                        :field/placeholder {:en "placeholder"}
                         :field/value lipsum-paragraphs
                         :field/previous-value previous-lipsum-paragraphs
                         :diff true}]])
@@ -362,7 +362,7 @@
                [:form
                 [field {:field/type :texta
                         :field/title {:en "Title"}
-                        :field/placeholder {:en "prompt"}
+                        :field/placeholder {:en "placeholder"}
                         :readonly true
                         :field/value lipsum-paragraphs
                         :field/previous-value previous-lipsum-paragraphs}]])
@@ -370,7 +370,7 @@
                [:form
                 [field {:field/type :texta
                         :field/title {:en "Title"}
-                        :field/placeholder {:en "prompt"}
+                        :field/placeholder {:en "placeholder"}
                         :readonly true
                         :field/value lipsum-paragraphs
                         :field/previous-value previous-lipsum-paragraphs
@@ -379,7 +379,7 @@
                [:form
                 [field {:field/type :texta
                         :field/title {:en "Title"}
-                        :field/placeholder {:en "prompt"}
+                        :field/placeholder {:en "placeholder"}
                         :readonly true
                         :field/value lipsum-paragraphs
                         :field/previous-value lipsum-paragraphs}]])])
@@ -501,7 +501,7 @@
              [field {:field/type :texta
                      :field/optional true
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}}]])
+                     :field/placeholder {:en "placeholder"}}]])
    (example "field of type \"label\""
             [:form
              [field {:field/type :label
@@ -510,4 +510,4 @@
             [:form
              [field {:field/type :description
                      :field/title {:en "Title"}
-                     :field/placeholder {:en "prompt"}}]])])
+                     :field/placeholder {:en "placeholder"}}]])])
diff --git a/src/cljs/rems/modal.cljs b/src/cljs/rems/modal.cljs
index 808a48598..24c287943 100644
--- a/src/cljs/rems/modal.cljs
+++ b/src/cljs/rems/modal.cljs
@@ -48,12 +48,7 @@
                   :title-class title-class
                   :always [:div.full
                            ;; max-height in order to keep header and controls visible
-                           [:div.modal--content
-                            {:style {:max-height "70vh" :overflow :auto}
-                             :ref (fn [elem] (when elem
-                                               (.focus elem)))
-                             :tabIndex "-1"}
-                            content]
+                           [:div.modal--content {:style {:max-height "70vh" :overflow :auto}} content]
                            (into [:div.modal--commands.commands {:style {:padding 0}}]
                                  commands)]
                   :open? true}]]


Test patch:
diff --git a/src/clj/rems/db/test_data.clj b/src/clj/rems/db/test_data.clj
index 1af25b020..47cf91b8c 100644
--- a/src/clj/rems/db/test_data.clj
+++ b/src/clj/rems/db/test_data.clj
@@ -114,75 +114,75 @@
         {:organization "nbn"
          :title "Basic form"
          :fields [;; all form field types
-                  {:title {:en "Project name"
-                           :fi "Projektin nimi"}
-                   :optional false
-                   :type "description"
-                   :input-prompt {:en "Project"
-                                  :fi "Projekti"}}
-
-                  {:title {:en "Here would be some helpful instructions."
-                           :fi "Tässä olisi jotain täyttöohjeita."}
-                   :optional false
-                   :type "label"}
-
-                  {:title {:en "Purpose of the project"
-                           :fi "Projektin tarkoitus"}
-                   :optional false
-                   :type "texta"
-                   :input-prompt {:en "The purpose of the project is to..."
-                                  :fi "Projektin tarkoitus on..."}}
-
-                  {:title {:en "Start date of the project"
-                           :fi "Projektin aloituspäivä"}
-                   :optional true
-                   :type "date"}
-
-                  {:title {:en "Project plan"
-                           :fi "Projektisuunnitelma"}
-                   :optional true
-                   :type "attachment"}
-
-                  {:title {:en "Project team size"
-                           :fi "Projektitiimin koko"}
-                   :optional true
-                   :type "option"
-                   :options [{:key "1-5"
-                              :label {:en "1-5 persons"
-                                      :fi "1-5 henkilöä"}}
-                             {:key "6-20"
-                              :label {:en "6-20 persons"
-                                      :fi "6-20 henkilöä"}}
-                             {:key "20+"
-                              :label {:en "over 20 persons"
-                                      :fi "yli 20 henkilöä"}}]}
-
-                  {:title {:en "Where will the data be used?"
-                           :fi "Missä dataa tullaan käyttämään?"}
-                   :optional true
-                   :type "multiselect"
-                   :options [{:key "EU"
-                              :label {:en "Inside EU"
-                                      :fi "EU:n sisällä"}}
-                             {:key "USA"
-                              :label {:en "Inside USA"
-                                      :fi "Yhdysvalloissa"}}
-                             {:key "Other"
-                              :label {:en "Elsewhere"
-                                      :fi "Muualla"}}]}
+                  {:field/title {:en "Project name"
+                                 :fi "Projektin nimi"}
+                   :field/optional false
+                   :field/type :description
+                   :field/placeholder {:en "Project"
+                                       :fi "Projekti"}}
+
+                  {:field/title {:en "Here would be some helpful instructions."
+                                 :fi "Tässä olisi jotain täyttöohjeita."}
+                   :field/optional false
+                   :field/type :label}
+
+                  {:field/title {:en "Purpose of the project"
+                                 :fi "Projektin tarkoitus"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/placeholder {:en "The purpose of the project is to..."
+                                       :fi "Projektin tarkoitus on..."}}
+
+                  {:field/title {:en "Start date of the project"
+                                 :fi "Projektin aloituspäivä"}
+                   :field/optional true
+                   :field/type :date}
+
+                  {:field/title {:en "Project plan"
+                                 :fi "Projektisuunnitelma"}
+                   :field/optional true
+                   :field/type :attachment}
+
+                  {:field/title {:en "Project team size"
+                                 :fi "Projektitiimin koko"}
+                   :field/optional true
+                   :field/type :option
+                   :field/options [{:key "1-5"
+                                    :label {:en "1-5 persons"
+                                            :fi "1-5 henkilöä"}}
+                                   {:key "6-20"
+                                    :label {:en "6-20 persons"
+                                            :fi "6-20 henkilöä"}}
+                                   {:key "20+"
+                                    :label {:en "over 20 persons"
+                                            :fi "yli 20 henkilöä"}}]}
+
+                  {:field/title {:en "Where will the data be used?"
+                                 :fi "Missä dataa tullaan käyttämään?"}
+                   :field/optional true
+                   :field/type :multiselect
+                   :field/options [{:key "EU"
+                                    :label {:en "Inside EU"
+                                            :fi "EU:n sisällä"}}
+                                   {:key "USA"
+                                    :label {:en "Inside USA"
+                                            :fi "Yhdysvalloissa"}}
+                                   {:key "Other"
+                                    :label {:en "Elsewhere"
+                                            :fi "Muualla"}}]}
 
                   ;; fields which support maxlength
-                  {:title {:en "Project acronym"
-                           :fi "Projektin lyhenne"}
-                   :optional true
-                   :type "text"
-                   :maxlength 10}
-
-                  {:title {:en "Research plan"
-                           :fi "Tutkimussuunnitelma"}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}]})))
+                  {:field/title {:en "Project acronym"
+                                 :fi "Projektin lyhenne"}
+                   :field/optional true
+                   :field/type :text
+                   :field/max-length 10}
+
+                  {:field/title {:en "Research plan"
+                                 :fi "Tutkimussuunnitelma"}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}]})))
 
 (defn create-thl-demo-form!
   [users]
@@ -190,202 +190,202 @@
         (users :owner)
         {:organization "nbn"
          :title "THL form"
-         :fields [{:title {:en "Application title"
-                           :fi "Hakemuksen otsikko"}
-                   :optional true
-                   :type "description"
-                   :input-prompt {:en "Study of.."
-                                  :fi "Tutkimus aiheesta.."}}
-                  {:title {:en "1. Research project full title"
-                           :fi "1. Tutkimusprojektin täysi nimi"}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "2. This is an amendment of a previous approved application"
-                           :fi "2. Hakemus täydentää edellistä hakemusta"}
-                   :optional false
-                   :type "option"
-                   :options [{:key "false"
-                              :label {:en "no"
-                                      :fi "ei"}}
-                             {:key "true"
-                              :label {:en "yes"
-                                      :fi "kyllä"}}]}
-                  {:title {:en "If yes, what were the previous project permit code/s?"
-                           :fi "Jos kyllä, mitkä olivat edelliset projektin lupakoodit?"}
-                   :optional true
-                   :type "text"}
-                  {:title {:en "3. Study PIs (name, titile, affiliation, email)"
-                           :fi "3. Henkilöstö (nimi, titteli, yhteys projektiin, sähköposti)"}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "4. Contact person for application if different than applicant (name, email)"
-                           :fi "4. Yhteyshenkilö, jos ei sama kuin hakija (nimi, sähköposti)"}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "5. Research project start date"
-                           :fi "5. Projektin aloituspäivä"}
-                   :optional false
-                   :type "date"}
-                  {:title {:en "6. Research project end date"
-                           :fi "6. Projektin lopetuspäivä"}
-                   :optional false
-                   :type "date"}
-                  {:title {:en "7. Describe in detail the aims of the study and analysis plan"
-                           :fi "7. Kuvaile yksityiskohtaisesti tutkimussuunnitelma"}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "8. If this is an amendment, please describe briefly what is new"
-                           :fi "8. Jos tämä on täydennys edelliseen hakemukseen, kuvaile tiiviisti, mikä on muuttunut."}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "9. Public description of the project (in Finnish, when possible), to be published in THL Biobank."
-                           :fi "9. Kuvaile yksityiskohtaisesti tutkimussuunnitelma"}
-                   :input-prompt {:en "Meant for sample donors and for anyone interested in the research done using THL Biobank's sample collections. This summary and the name of the Study PI will be published in THL Biobank's web pages."
-                                  :fi "Tarkoitettu aineistojen lahjoittajille ja kaikille, joita kiinnostaa THL:n Biopankkia käyttävät tutkimusprojektit. Tämä kuvaus sekä tutkijan nimi julkaistaan THL:n nettisivuilla, kun sopimus on allekirjoitettu."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "10. Place/plces of research, including place of sample and/or data analysis."
-                           :fi "10. Tutkimuksen yysinen sijainti, mukaanlukien paikka, missä data-analyysi toteutetaan."}
-                   :input-prompt {:en "List all research center involved in this study, and each center's role. Specify which centers will analyze which data and/or samples.."
-                                  :fi "Listaa kaikki tutkimuskeskukset, jotka osallistuvat tähän tutkimukseen, ml. niiden roolit tutkimuksessa. Erittele, missä analysoidaan mikäkin näyte."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "11. Description of other research group members and their role in the applied project."
-                           :fi "11. Kuvaus muista tutkimukseen osallistuvista henkilöistä, ja heidän roolistaan projektissa."}
-                   :input-prompt {:en "For every group member: name, title, affiliation, contact information. In addition describe earch member's role in the project (e.g. cohor representative, data analyst, etc.)"
-                                  :fi "Anna jokaisesta jäsenestä: nimi, titteli, yhteys projektiin, yhteystiedot. Kuvaile lisäki jokaisen henkilön rooli projektissa."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "12. Specify selection criteria of study participants (if applicable)"
-                           :fi "12. Erottele tukimuksen osallistujien valintakriteerit (jos käytetty)"}
-                   :input-prompt {:en "Describe any specific criteria by which study participans will be selected. For example, selection for specific age group, gender, area/locality, disease status etc."
-                                  :fi "Kuvaa tarkat valintakriteerit, joilla tutkimuksen osallistujat valitaan. Esimerkiksi ikäryhmä, sukupuoli, alue, taudin tila jne."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "13. Specify requested phenotype data (information on variables is found at https://kite.fimm.fi)"
-                           :fi "13. Tarkenna pyydetty fenotyyppidatta (tietoa muuttujista on saatavilla osoitteesta https://kite.fimm.fi)"}
-                   :input-prompt {:en "Desrcibe in detail the phenotype data needed for the study. Lists of variables are to be attached to the application (below)."
-                                  :fi "Kuvaile yksityiskohtaisesti tutkimukseen tarvittava fenotyyppidata. Lista muuttujista lisätään hakemukseen liitteenä."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "14. Specify requested genomics or other omics data (if applicable)"
-                           :fi "14. Kuvaile tarvittava genomiikkadata."}
-                   :input-prompt {:en "Specify in detail the requested data format for different genomics or other omics data types. Information of available omics data is found at THL Biobank web page (www.thl.fi/biobank/researchers)"
-                                  :fi "Kuvaile tarvitsemasi genomiikkadata. Lisätietoa saatavilla osoitteesta www.thl.fi/biobank/researchers"}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "16. Are biological samples requested?"
-                           :fi "16. Pyydetäänkö biologisia näytteitä?"}
-                   :optional false
-                   :type "option"
-                   :options [{:key "false"
-                              :label {:en "no"
-                                      :fi "ei"}}
-                             {:key "true"
-                              :label {:en "yes"
-                                      :fi "kyllä"}}]}
-                  {:title {:en "The type and amount of biological samples requested"
-                           :fi "Biologisten näytteiden tyypit ja määrät."}
-                   :input-prompt {:en "Type and amount of samples and any additional specific criteria."
-                                  :fi "Biologisten näytteiden määrät, tyypit, ja mahdolliset muut kriteerit."}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "17. What study results will be returned to THL Biobank (if any)?"
-                           :fi "17. Mitä tutkimustuloksia tullaan palauttamaan THL Biopankkiin?"}
-                   :input-prompt {:en "Study results such as new laboratory measurements, produced omics data and other analysis data (\"raw data\")"
-                                  :fi "Tutkimustuloksia kuten mittaustuloksia, uutta biologista dataa, tai muita analyysien tuloksia (\"raaka-dataa\")"}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "Expected date for return of study results"
-                           :fi "Odotettu tutkimustuloksien palautuspäivämäärä"}
-                   :optional true
-                   :type "date"}
-                  {:title {:en "18. Ethical aspects of the project"
-                           :fi "18. Tutkimuksen eettiset puolet"}
-                   :input-prompt {:en "If you have any documents from an ethical board, please provide them as an attachment."
-                                  :fi "Liitä mahdolliset eettisen toimikunnan lausunnot hakemuksen loppuun."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "19. Project keywords (max 5)"
-                           :fi "19. Projektin avainsanat (maks. 5)"}
-                   :input-prompt {:en "List a few keywords that are related to this research project (please separate with comma)"
-                                  :fi "Listaa muutama projektiin liittyvä avainsana, pilkuilla erotettuina."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "20. Planned publications (max 3)"
-                           :fi "20. Suunnitellut julkaisut (maks. 3)"}
-                   :input-prompt {:en "Planned publication titles / research topics"
-                                  :fi "Suunniteltujen julkaisujen otsikot / tutkimusaiheet"}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "21. Funding information"
-                           :fi "21. Rahoitus"}
-                   :input-prompt {:en "List all funding sources which will be used for this research project."
-                                  :fi "Listaa kaikki rahoituslähteet joita tullaan käyttämään tähän tutkimusprojektiin"}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "22. Invoice address (Service prices: www.thl.fi/biobank/researchers)"
-                           :fi "22. Laskutusosoite (Palveluhinnasto: www.thl.fi/biobank/researchers)"}
-                   :input-prompt {:en "Electronic invoice address when possible + invoicing reference"
-                                  :fi "Sähköinen laskutus, kun mahdollista. Lisäksi viitenumero."}
-                   :optional false
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "23. Other information"
-                           :fi "23. Muuta"}
-                   :input-prompt {:en "Any other relevant information for the application"
-                                  :fi "Muuta hakemukseen liittyvää oleellista tietoa"}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "THL Biobank's registered area/s of operation to which the research project complies:"
-                           :fi "THL Biobankin toimialueet, joihin tutkimusprojekti liittyy:"}
-                   :optional false
-                   :type "multiselect"
-                   :options [{:key "population_health"
-                              :label {:en "Promoting the population's health"
-                                      :fi "Edistää kansanterveytttä"}}
-                             {:key "disease_mechanisms"
-                              :label {:en "Identifying factors involved in disease mechanisms"
-                                      :fi "Tunnistaa tautien mekanismeja"}}
-                             {:key "disease_prevention"
-                              :label {:en "Disease prevention"
-                                      :fi "Estää tautien leviämistä"}}
-                             {:key "health_product_development"
-                              :label {:en "Developing products that promote the welfare and health of the population"
-                                      :fi "Kehittää tuotteita, jotka edistävät kansanterveyttä."}}
-                             {:key "treatment_development"
-                              :label {:en "Developing products and treatments for diseases"
-                                      :fi "Kehittää tuotteita ja parannuskeinoja tautien varalle"}}
-                             {:key "other"
-                              :label {:en "Other"
-                                      :fi "Muuta"}}]}
-                  {:title {:en "Other, specify"
-                           :fi "Muuta, tarkenna"}
-                   :optional true
-                   :type "texta"
-                   :maxlength 100}
-                  {:title {:en "Data management plan (pdf)"
-                           :fi "Datanhallintasuunnitelma (pdf)"}
-                   :optional true
-                   :type "attachment"}]})))
+         :fields [{:field/title {:en "Application title"
+                                 :fi "Hakemuksen otsikko"}
+                   :field/optional true
+                   :field/type :description
+                   :field/placeholder {:en "Study of.."
+                                       :fi "Tutkimus aiheesta.."}}
+                  {:field/title {:en "1. Research project full title"
+                                 :fi "1. Tutkimusprojektin täysi nimi"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "2. This is an amendment of a previous approved application"
+                                 :fi "2. Hakemus täydentää edellistä hakemusta"}
+                   :field/optional false
+                   :field/type :option
+                   :field/options [{:key "false"
+                                    :label {:en "no"
+                                            :fi "ei"}}
+                                   {:key "true"
+                                    :label {:en "yes"
+                                            :fi "kyllä"}}]}
+                  {:field/title {:en "If yes, what were the previous project permit code/s?"
+                                 :fi "Jos kyllä, mitkä olivat edelliset projektin lupakoodit?"}
+                   :field/optional true
+                   :field/type :text}
+                  {:field/title {:en "3. Study PIs (name, titile, affiliation, email)"
+                                 :fi "3. Henkilöstö (nimi, titteli, yhteys projektiin, sähköposti)"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "4. Contact person for application if different than applicant (name, email)"
+                                 :fi "4. Yhteyshenkilö, jos ei sama kuin hakija (nimi, sähköposti)"}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "5. Research project start date"
+                                 :fi "5. Projektin aloituspäivä"}
+                   :field/optional false
+                   :field/type :date}
+                  {:field/title {:en "6. Research project end date"
+                                 :fi "6. Projektin lopetuspäivä"}
+                   :field/optional false
+                   :field/type :date}
+                  {:field/title {:en "7. Describe in detail the aims of the study and analysis plan"
+                                 :fi "7. Kuvaile yksityiskohtaisesti tutkimussuunnitelma"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "8. If this is an amendment, please describe briefly what is new"
+                                 :fi "8. Jos tämä on täydennys edelliseen hakemukseen, kuvaile tiiviisti, mikä on muuttunut."}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "9. Public description of the project (in Finnish, when possible), to be published in THL Biobank."
+                                 :fi "9. Kuvaile yksityiskohtaisesti tutkimussuunnitelma"}
+                   :field/placeholder {:en "Meant for sample donors and for anyone interested in the research done using THL Biobank's sample collections. This summary and the name of the Study PI will be published in THL Biobank's web pages."
+                                       :fi "Tarkoitettu aineistojen lahjoittajille ja kaikille, joita kiinnostaa THL:n Biopankkia käyttävät tutkimusprojektit. Tämä kuvaus sekä tutkijan nimi julkaistaan THL:n nettisivuilla, kun sopimus on allekirjoitettu."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "10. Place/plces of research, including place of sample and/or data analysis."
+                                 :fi "10. Tutkimuksen yysinen sijainti, mukaanlukien paikka, missä data-analyysi toteutetaan."}
+                   :field/placeholder {:en "List all research center involved in this study, and each center's role. Specify which centers will analyze which data and/or samples.."
+                                       :fi "Listaa kaikki tutkimuskeskukset, jotka osallistuvat tähän tutkimukseen, ml. niiden roolit tutkimuksessa. Erittele, missä analysoidaan mikäkin näyte."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "11. Description of other research group members and their role in the applied project."
+                                 :fi "11. Kuvaus muista tutkimukseen osallistuvista henkilöistä, ja heidän roolistaan projektissa."}
+                   :field/placeholder {:en "For every group member: name, title, affiliation, contact information. In addition describe earch member's role in the project (e.g. cohor representative, data analyst, etc.)"
+                                       :fi "Anna jokaisesta jäsenestä: nimi, titteli, yhteys projektiin, yhteystiedot. Kuvaile lisäki jokaisen henkilön rooli projektissa."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "12. Specify selection criteria of study participants (if applicable)"
+                                 :fi "12. Erottele tukimuksen osallistujien valintakriteerit (jos käytetty)"}
+                   :field/placeholder {:en "Describe any specific criteria by which study participans will be selected. For example, selection for specific age group, gender, area/locality, disease status etc."
+                                       :fi "Kuvaa tarkat valintakriteerit, joilla tutkimuksen osallistujat valitaan. Esimerkiksi ikäryhmä, sukupuoli, alue, taudin tila jne."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "13. Specify requested phenotype data (information on variables is found at https://kite.fimm.fi)"
+                                 :fi "13. Tarkenna pyydetty fenotyyppidatta (tietoa muuttujista on saatavilla osoitteesta https://kite.fimm.fi)"}
+                   :field/placeholder {:en "Desrcibe in detail the phenotype data needed for the study. Lists of variables are to be attached to the application (below)."
+                                       :fi "Kuvaile yksityiskohtaisesti tutkimukseen tarvittava fenotyyppidata. Lista muuttujista lisätään hakemukseen liitteenä."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "14. Specify requested genomics or other omics data (if applicable)"
+                                 :fi "14. Kuvaile tarvittava genomiikkadata."}
+                   :field/placeholder {:en "Specify in detail the requested data format for different genomics or other omics data types. Information of available omics data is found at THL Biobank web page (www.thl.fi/biobank/researchers)"
+                                       :fi "Kuvaile tarvitsemasi genomiikkadata. Lisätietoa saatavilla osoitteesta www.thl.fi/biobank/researchers"}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "16. Are biological samples requested?"
+                                 :fi "16. Pyydetäänkö biologisia näytteitä?"}
+                   :field/optional false
+                   :field/type :option
+                   :field/options [{:key "false"
+                                    :label {:en "no"
+                                            :fi "ei"}}
+                                   {:key "true"
+                                    :label {:en "yes"
+                                            :fi "kyllä"}}]}
+                  {:field/title {:en "The type and amount of biological samples requested"
+                                 :fi "Biologisten näytteiden tyypit ja määrät."}
+                   :field/placeholder {:en "Type and amount of samples and any additional specific criteria."
+                                       :fi "Biologisten näytteiden määrät, tyypit, ja mahdolliset muut kriteerit."}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "17. What study results will be returned to THL Biobank (if any)?"
+                                 :fi "17. Mitä tutkimustuloksia tullaan palauttamaan THL Biopankkiin?"}
+                   :field/placeholder {:en "Study results such as new laboratory measurements, produced omics data and other analysis data (\"raw data\")"
+                                       :fi "Tutkimustuloksia kuten mittaustuloksia, uutta biologista dataa, tai muita analyysien tuloksia (\"raaka-dataa\")"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "Expected date for return of study results"
+                                 :fi "Odotettu tutkimustuloksien palautuspäivämäärä"}
+                   :field/optional true
+                   :field/type :date}
+                  {:field/title {:en "18. Ethical aspects of the project"
+                                 :fi "18. Tutkimuksen eettiset puolet"}
+                   :field/placeholder {:en "If you have any documents from an ethical board, please provide them as an attachment."
+                                       :fi "Liitä mahdolliset eettisen toimikunnan lausunnot hakemuksen loppuun."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "19. Project keywords (max 5)"
+                                 :fi "19. Projektin avainsanat (maks. 5)"}
+                   :field/placeholder {:en "List a few keywords that are related to this research project (please separate with comma)"
+                                       :fi "Listaa muutama projektiin liittyvä avainsana, pilkuilla erotettuina."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "20. Planned publications (max 3)"
+                                 :fi "20. Suunnitellut julkaisut (maks. 3)"}
+                   :field/placeholder {:en "Planned publication titles / research topics"
+                                       :fi "Suunniteltujen julkaisujen otsikot / tutkimusaiheet"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "21. Funding information"
+                                 :fi "21. Rahoitus"}
+                   :field/placeholder {:en "List all funding sources which will be used for this research project."
+                                       :fi "Listaa kaikki rahoituslähteet joita tullaan käyttämään tähän tutkimusprojektiin"}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "22. Invoice address (Service prices: www.thl.fi/biobank/researchers)"
+                                 :fi "22. Laskutusosoite (Palveluhinnasto: www.thl.fi/biobank/researchers)"}
+                   :field/placeholder {:en "Electronic invoice address when possible + invoicing reference"
+                                       :fi "Sähköinen laskutus, kun mahdollista. Lisäksi viitenumero."}
+                   :field/optional false
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "23. Other information"
+                                 :fi "23. Muuta"}
+                   :field/placeholder {:en "Any other relevant information for the application"
+                                       :fi "Muuta hakemukseen liittyvää oleellista tietoa"}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "THL Biobank's registered area/s of operation to which the research project complies:"
+                                 :fi "THL Biobankin toimialueet, joihin tutkimusprojekti liittyy:"}
+                   :field/optional false
+                   :field/type :multiselect
+                   :field/options [{:key "population_health"
+                                    :label {:en "Promoting the population's health"
+                                            :fi "Edistää kansanterveytttä"}}
+                                   {:key "disease_mechanisms"
+                                    :label {:en "Identifying factors involved in disease mechanisms"
+                                            :fi "Tunnistaa tautien mekanismeja"}}
+                                   {:key "disease_prevention"
+                                    :label {:en "Disease prevention"
+                                            :fi "Estää tautien leviämistä"}}
+                                   {:key "health_product_development"
+                                    :label {:en "Developing products that promote the welfare and health of the population"
+                                            :fi "Kehittää tuotteita, jotka edistävät kansanterveyttä."}}
+                                   {:key "treatment_development"
+                                    :label {:en "Developing products and treatments for diseases"
+                                            :fi "Kehittää tuotteita ja parannuskeinoja tautien varalle"}}
+                                   {:key "other"
+                                    :label {:en "Other"
+                                            :fi "Muuta"}}]}
+                  {:field/title {:en "Other, specify"
+                                 :fi "Muuta, tarkenna"}
+                   :field/optional true
+                   :field/type :texta
+                   :field/max-length 100}
+                  {:field/title {:en "Data management plan (pdf)"
+                                 :fi "Datanhallintasuunnitelma (pdf)"}
+                   :field/optional true
+                   :field/type :attachment}]})))
 
 (defn- create-workflows! [users]
   (let [approver1 (users :approver1)
@@ -650,6 +650,9 @@
         application (create-draft! applicant item-without-new-license wfid "applied before license was valid" (time/minus (time/now) (time/days 2)))]
     (legacy/submit-application applicant application)))
 
+(defn- assert-no-error [error]
+  (assert (nil? error) {:error error}))
+
 (defn create-performance-test-data! []
   (let [resource-count 1000
         application-count 1000
@@ -666,19 +669,19 @@
                       owner
                       {:organization "perf"
                        :title "Performance tests"
-                       :fields [{:title {:en "Project name"
-                                         :fi "Projektin nimi"}
-                                 :optional false
-                                 :type "description"
-                                 :input-prompt {:en "Project"
-                                                :fi "Projekti"}}
-
-                                {:title {:en "Project description"
-                                         :fi "Projektin kuvaus"}
-                                 :optional false
-                                 :type "texta"
-                                 :input-prompt {:en "The purpose of the project is to..."
-                                                :fi "Projektin tarkoitus on..."}}]}))
+                       :fields [{:field/title {:en "Project name"
+                                               :fi "Projektin nimi"}
+                                 :field/optional false
+                                 :field/type :description
+                                 :field/placeholder {:en "Project"
+                                                     :fi "Projekti"}}
+
+                                {:field/title {:en "Project description"
+                                               :fi "Projektin kuvaus"}
+                                 :field/optional false
+                                 :field/type :texta
+                                 :field/placeholder {:en "The purpose of the project is to..."
+                                                     :fi "Projektin tarkoitus on..."}}]}))
         form (form/get-form-template form-id)
         license-id (:id (licenses/create-license!
                          {:licensetype "text"
@@ -713,30 +716,33 @@
             user-id (rand-nth user-ids)
             handler (rand-nth handlers)
             app-id (:application-id (applications/create-application! user-id [cat-item-id]))]
-        (assert (nil? (applications/command!
-                       {:type :application.command/save-draft
-                        :actor user-id
-                        :time (time/now)
-                        :application-id app-id
-                        :field-values [{:field (:id (first (:fields form)))
-                                        :value (str "Performance test application " (UUID/randomUUID))}
-                                       {:field (:id (second (:fields form)))
-                                        ;; 5000 characters (10 KB) of lorem ipsum generated with www.lipsum.com
-                                        ;; to increase the memory requirements of an application
-                                        :value (str "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non diam vel erat dapibus facilisis vel vitae nunc. Curabitur at fermentum lorem. Cras et bibendum ante. Etiam convallis erat justo. Phasellus cursus molestie vehicula. Etiam molestie tellus vitae consectetur dignissim. Pellentesque euismod hendrerit mi sed tincidunt. Integer quis lorem ut ipsum egestas hendrerit. Aenean est nunc, mattis euismod erat in, sodales rutrum mauris. Praesent sit amet risus quis felis congue ultricies. Nulla facilisi. Sed mollis justo id tristique volutpat.\n\nPhasellus augue mi, facilisis ac velit et, pharetra tristique nunc. Pellentesque eget arcu quam. Curabitur dictum nulla varius hendrerit varius. Proin vulputate, ex lacinia commodo varius, ipsum velit viverra est, eget molestie dui nisi non eros. Nulla lobortis odio a magna mollis placerat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer consectetur libero ut gravida ullamcorper. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec aliquam feugiat mollis. Quisque massa lacus, efficitur vel justo vel, elementum mollis magna. Maecenas at sem sem. Praesent sed ex mattis, egestas dui non, volutpat lorem. Nulla tempor, nisi rutrum accumsan varius, tellus elit faucibus nulla, vel mattis lacus justo at ante. Sed ut mollis ex, sed tincidunt ex.\n\nMauris laoreet nibh eget erat tincidunt pharetra. Aenean sagittis maximus consectetur. Curabitur interdum nibh sed tincidunt finibus. Sed blandit nec lorem at iaculis. Morbi non augue nec tortor hendrerit mollis ut non arcu. Suspendisse maximus nec ligula a efficitur. Etiam ultrices rhoncus leo quis dapibus. Integer vel rhoncus est. Integer blandit varius auctor. Vestibulum suscipit suscipit risus, sit amet venenatis lacus iaculis a. Duis eu turpis sit amet nibh sagittis convallis at quis ligula. Sed eget justo quis risus iaculis lacinia vitae a justo. In hac habitasse platea dictumst. Maecenas euismod et lorem vel viverra.\n\nDonec bibendum nec ipsum in volutpat. Vivamus in elit venenatis, venenatis libero ac, ultrices dolor. Morbi quis odio in neque consequat rutrum. Suspendisse quis sapien id sapien fermentum dignissim. Nam eu est vel risus volutpat mollis sed quis eros. Proin leo nulla, dictum id hendrerit vitae, scelerisque in elit. Proin consectetur sodales arcu ac tristique. Suspendisse ut elementum ligula, at rhoncus mauris. Aliquam lacinia at diam eget mattis. Phasellus quam leo, hendrerit sit amet mi eget, porttitor aliquet velit. Proin turpis ante, consequat in enim nec, tempus consequat magna. Vestibulum fringilla ac turpis nec malesuada. Proin id lectus iaculis, suscipit erat at, volutpat turpis. In quis faucibus elit, ut maximus nibh. Sed egestas egestas dolor.\n\nNulla varius orci quam, id auctor enim ultrices nec. Morbi et tellus ac metus sodales convallis sed vehicula neque. Pellentesque rhoncus mattis massa a bibendum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce tincidunt nulla non aliquet facilisis. Praesent nisl nisi, finibus id odio sed, consectetur feugiat mauris. Suspendisse sed lacinia ligula. Duis vitae nisl leo. Donec erat arcu, feugiat sit amet sagittis ac, scelerisque nec est. Pellentesque finibus mauris nulla, in maximus sapien pharetra vitae. Sed leo elit, consequat eu aliquam vitae, feugiat ut eros. Pellentesque dictum feugiat odio sed commodo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin neque quam, varius vel libero sit amet, rhoncus sollicitudin ex. In a dui non neque malesuada pellentesque.\n\nProin tincidunt nisl non commodo faucibus. Sed porttitor arcu neque, vitae bibendum sapien placerat nec. Integer eget tristique orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec eu molestie eros. Nunc iaculis rhoncus enim, vel mattis felis fringilla condimentum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean ac augue nulla. Phasellus vitae nulla lobortis, mattis magna ac, gravida ipsum. Aenean ornare non nunc non luctus. Aenean lacinia lectus nec velit finibus egestas vel ut ipsum. Cras hendrerit rhoncus erat, vel maximus nunc.\n\nPraesent quis imperdiet quam. Praesent ligula tellus, consectetur sed lacus eu, malesuada condimentum tellus. Donec et diam hendrerit, dictum diam quis, aliquet purus. Suspendisse pulvinar neque at efficitur iaculis. Nulla erat orci, euismod id velit sed, dictum hendrerit arcu. Nulla aliquam molestie aliquam. Duis et semper nisi, eget commodo arcu. Praesent rhoncus, nulla id sodales eleifend, ante ipsum pellentesque augue, id iaculis sem est vitae est. Phasellus cursus diam a lorem vestibulum sodales. Nullam lacinia tortor vel tellus commodo, sit amet sodales quam malesuada.\n\nNulla tempor lectus vel arcu feugiat, vel dapibus ex dapibus. Maecenas purus justo, aliquet et sem sit amet, tincidunt venenatis dui. Nulla eget purus id sapien elementum rutrum eu vel libero. Cras non accumsan justo posuere.\n\n"
-                                                    ;; prevent string interning, just to be sure
-                                                    (UUID/randomUUID))}]})))
-        (assert (nil? (applications/command!
-                       {:type :application.command/submit
-                        :actor user-id
-                        :time (time/now)
-                        :application-id app-id})))
-        (assert (nil? (applications/command!
-                       {:type :application.command/approve
-                        :actor handler
-                        :time (time/now)
-                        :application-id app-id
-                        :comment "Looks fine."})))))))
+        (assert-no-error
+         (applications/command!
+          {:type :application.command/save-draft
+           :actor user-id
+           :time (time/now)
+           :application-id app-id
+           :field-values [{:field (:field/id (first (:fields form)))
+                           :value (str "Performance test application " (UUID/randomUUID))}
+                          {:field (:field/id (second (:fields form)))
+                           ;; 5000 characters (10 KB) of lorem ipsum generated with www.lipsum.com
+                           ;; to increase the memory requirements of an application
+                           :value (str "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non diam vel erat dapibus facilisis vel vitae nunc. Curabitur at fermentum lorem. Cras et bibendum ante. Etiam convallis erat justo. Phasellus cursus molestie vehicula. Etiam molestie tellus vitae consectetur dignissim. Pellentesque euismod hendrerit mi sed tincidunt. Integer quis lorem ut ipsum egestas hendrerit. Aenean est nunc, mattis euismod erat in, sodales rutrum mauris. Praesent sit amet risus quis felis congue ultricies. Nulla facilisi. Sed mollis justo id tristique volutpat.\n\nPhasellus augue mi, facilisis ac velit et, pharetra tristique nunc. Pellentesque eget arcu quam. Curabitur dictum nulla varius hendrerit varius. Proin vulputate, ex lacinia commodo varius, ipsum velit viverra est, eget molestie dui nisi non eros. Nulla lobortis odio a magna mollis placerat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer consectetur libero ut gravida ullamcorper. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec aliquam feugiat mollis. Quisque massa lacus, efficitur vel justo vel, elementum mollis magna. Maecenas at sem sem. Praesent sed ex mattis, egestas dui non, volutpat lorem. Nulla tempor, nisi rutrum accumsan varius, tellus elit faucibus nulla, vel mattis lacus justo at ante. Sed ut mollis ex, sed tincidunt ex.\n\nMauris laoreet nibh eget erat tincidunt pharetra. Aenean sagittis maximus consectetur. Curabitur interdum nibh sed tincidunt finibus. Sed blandit nec lorem at iaculis. Morbi non augue nec tortor hendrerit mollis ut non arcu. Suspendisse maximus nec ligula a efficitur. Etiam ultrices rhoncus leo quis dapibus. Integer vel rhoncus est. Integer blandit varius auctor. Vestibulum suscipit suscipit risus, sit amet venenatis lacus iaculis a. Duis eu turpis sit amet nibh sagittis convallis at quis ligula. Sed eget justo quis risus iaculis lacinia vitae a justo. In hac habitasse platea dictumst. Maecenas euismod et lorem vel viverra.\n\nDonec bibendum nec ipsum in volutpat. Vivamus in elit venenatis, venenatis libero ac, ultrices dolor. Morbi quis odio in neque consequat rutrum. Suspendisse quis sapien id sapien fermentum dignissim. Nam eu est vel risus volutpat mollis sed quis eros. Proin leo nulla, dictum id hendrerit vitae, scelerisque in elit. Proin consectetur sodales arcu ac tristique. Suspendisse ut elementum ligula, at rhoncus mauris. Aliquam lacinia at diam eget mattis. Phasellus quam leo, hendrerit sit amet mi eget, porttitor aliquet velit. Proin turpis ante, consequat in enim nec, tempus consequat magna. Vestibulum fringilla ac turpis nec malesuada. Proin id lectus iaculis, suscipit erat at, volutpat turpis. In quis faucibus elit, ut maximus nibh. Sed egestas egestas dolor.\n\nNulla varius orci quam, id auctor enim ultrices nec. Morbi et tellus ac metus sodales convallis sed vehicula neque. Pellentesque rhoncus mattis massa a bibendum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce tincidunt nulla non aliquet facilisis. Praesent nisl nisi, finibus id odio sed, consectetur feugiat mauris. Suspendisse sed lacinia ligula. Duis vitae nisl leo. Donec erat arcu, feugiat sit amet sagittis ac, scelerisque nec est. Pellentesque finibus mauris nulla, in maximus sapien pharetra vitae. Sed leo elit, consequat eu aliquam vitae, feugiat ut eros. Pellentesque dictum feugiat odio sed commodo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin neque quam, varius vel libero sit amet, rhoncus sollicitudin ex. In a dui non neque malesuada pellentesque.\n\nProin tincidunt nisl non commodo faucibus. Sed porttitor arcu neque, vitae bibendum sapien placerat nec. Integer eget tristique orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec eu molestie eros. Nunc iaculis rhoncus enim, vel mattis felis fringilla condimentum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean ac augue nulla. Phasellus vitae nulla lobortis, mattis magna ac, gravida ipsum. Aenean ornare non nunc non luctus. Aenean lacinia lectus nec velit finibus egestas vel ut ipsum. Cras hendrerit rhoncus erat, vel maximus nunc.\n\nPraesent quis imperdiet quam. Praesent ligula tellus, consectetur sed lacus eu, malesuada condimentum tellus. Donec et diam hendrerit, dictum diam quis, aliquet purus. Suspendisse pulvinar neque at efficitur iaculis. Nulla erat orci, euismod id velit sed, dictum hendrerit arcu. Nulla aliquam molestie aliquam. Duis et semper nisi, eget commodo arcu. Praesent rhoncus, nulla id sodales eleifend, ante ipsum pellentesque augue, id iaculis sem est vitae est. Phasellus cursus diam a lorem vestibulum sodales. Nullam lacinia tortor vel tellus commodo, sit amet sodales quam malesuada.\n\nNulla tempor lectus vel arcu feugiat, vel dapibus ex dapibus. Maecenas purus justo, aliquet et sem sit amet, tincidunt venenatis dui. Nulla eget purus id sapien elementum rutrum eu vel libero. Cras non accumsan justo posuere.\n\n"
+                                       ;; prevent string interning, just to be sure
+                                       (UUID/randomUUID))}]}))
+        (assert-no-error
+         (applications/command!
+          {:type :application.command/submit
+           :actor user-id
+           :time (time/now)
+           :application-id app-id}))
+        (assert-no-error
+         (applications/command!
+          {:type :application.command/approve
+           :actor handler
+           :time (time/now)
+           :application-id app-id
+           :comment "Looks fine."}))))))
 
 (defn create-test-data! []
   (DateTimeUtils/setCurrentMillisFixed (.getMillis creation-time))
diff --git a/test/clj/rems/api/test_applications.clj b/test/clj/rems/api/test_applications.clj
index 4f59ec0f4..552c6db08 100644
--- a/test/clj/rems/api/test_applications.clj
+++ b/test/clj/rems/api/test_applications.clj
@@ -282,13 +282,13 @@
         (testing "add licenses"
           (let [application (get-application application-id user-id)]
             (is (= #{1 2} (license-ids-for-application application)))
-           (is (= {:success true} (send-command handler-id
-                                                {:type :application.command/add-licenses
-                                                 :application-id application-id
-                                                 :licenses [license-id]
-                                                 :comment "Please approve these new terms"})))
-           (let [application (get-application application-id user-id)]
-             (is (= #{1 2 5} (license-ids-for-application application))))))
+            (is (= {:success true} (send-command handler-id
+                                                 {:type :application.command/add-licenses
+                                                  :application-id application-id
+                                                  :licenses [license-id]
+                                                  :comment "Please approve these new terms"})))
+            (let [application (get-application application-id user-id)]
+              (is (= #{1 2 5} (license-ids-for-application application))))))
         (testing "applicant accepts the additional licenses"
           (is (= {:success true} (send-command user-id
                                                {:type :application.command/accept-licenses
@@ -300,19 +300,19 @@
           (is (= #{9} (catalogue-item-ids-for-application application)))
           ;; License #5 was added previously by the handler.
           (is (= #{1 2 5} (license-ids-for-application application)))
-         (is (= {:success true} (send-command handler-id
-                                              {:type :application.command/change-resources
-                                               :application-id application-id
-                                               :catalogue-item-ids [9 10]
-                                               :comment "Here are the correct resources"})))
-         (let [application (get-application application-id user-id)]
-           (is (= #{9 10} (catalogue-item-ids-for-application application)))
-           ;; License #4 is added by the catalogue-item #10, whereas
-           ;; the previously added license #5 is dropped from the list.
-           ;;
-           ;; TODO: The previously added licenses should probably be retained
-           ;; in the licenses after changing resources.
-           (is (= #{1 2 4} (license-ids-for-application application))))))
+          (is (= {:success true} (send-command handler-id
+                                               {:type :application.command/change-resources
+                                                :application-id application-id
+                                                :catalogue-item-ids [9 10]
+                                                :comment "Here are the correct resources"})))
+          (let [application (get-application application-id user-id)]
+            (is (= #{9 10} (catalogue-item-ids-for-application application)))
+            ;; License #4 is added by the catalogue-item #10, whereas
+            ;; the previously added license #5 is dropped from the list.
+            ;;
+            ;; TODO: The previously added licenses should probably be retained
+            ;; in the licenses after changing resources.
+            (is (= #{1 2 4} (license-ids-for-application application))))))
 
       (testing "changing resources back as handler"
         (is (= {:success true} (send-command handler-id
@@ -439,15 +439,15 @@
 (deftest test-application-validation
   (let [user-id "alice"
         workflow-id (create-dynamic-workflow)
-        form-id (create-form-with-fields [{:title {:en "req"}
-                                           :type "text"
-                                           :optional false}
-                                          {:title {:en "opt"}
-                                           :type "text"
-                                           :optional true}])
+        form-id (create-form-with-fields [{:field/title {:en "req"}
+                                           :field/type :text
+                                           :field/optional false}
+                                          {:field/title {:en "opt"}
+                                           :field/type :text
+                                           :field/optional true}])
         [req-id opt-id] (->> (form/get-form-template form-id)
                              :fields
-                             (map :id))
+                             (map :field/id))
         cat-id (create-catalogue-item form-id workflow-id)
         app-id (create-application [cat-id] user-id)]
     (testing "set value of optional field"
@@ -489,9 +489,9 @@
   (let [api-key "42"
         user-id "alice"
         workflow-id (create-dynamic-workflow)
-        form-id (create-form-with-fields [{:title {:en "some attachment"}
-                                           :type "attachment"
-                                           :optional true}])
+        form-id (create-form-with-fields [{:field/title {:en "some attachment"}
+                                           :field/type :attachment
+                                           :field/optional true}])
         cat-id (create-catalogue-item form-id workflow-id)
         app-id (create-application [cat-id] user-id)
         upload-request (fn [file]
diff --git a/test/clj/rems/api/test_forms.clj b/test/clj/rems/api/test_forms.clj
index d177a7f0b..aed1ec9c5 100644
--- a/test/clj/rems/api/test_forms.clj
+++ b/test/clj/rems/api/test_forms.clj
@@ -1,8 +1,6 @@
 (ns ^:integration rems.api.test-forms
   (:require [clojure.test :refer :all]
             [rems.api.testing :refer :all]
-            [rems.db.core :as db]
-            [rems.db.form :as form]
             [rems.handler :refer [handler]]
             [ring.mock.request :refer :all])
   (:import (java.util UUID)))
@@ -11,6 +9,12 @@
   :once
   api-fixture)
 
+(defn fixup-field-to-match-command [field]
+  (-> field
+      (dissoc :field/id)
+      ;; XXX: these tests use the JSON API, so keywords are not maintained
+      (update :field/type keyword)))
+
 (deftest forms-api-test
   (let [api-key "42"
         user-id "owner"]
@@ -23,32 +27,46 @@
                      read-body)]
         (is (:id (first data)))))
 
+    (testing "get one"
+      (let [data (-> (request :get "/api/forms/1")
+                     (authenticate api-key user-id)
+                     handler
+                     assert-response-is-ok
+                     read-body)]
+        (is (:id data))))
+
+    (testing "not found"
+      (let [response (-> (request :get "/api/forms/0")
+                         (authenticate api-key user-id)
+                         handler)]
+        (is (= 404 (:status response)))))
+
     (testing "create"
       (let [command {:organization "abc"
                      :title (str "form title " (UUID/randomUUID))
-                     :fields [{:title {:en "en title"
-                                       :fi "fi title"}
-                               :optional true
-                               :type "text"
-                               :input-prompt {:en "en prompt"
-                                              :fi "fi prompt"}}]}]
+                     :fields [{:field/title {:en "en title"
+                                             :fi "fi title"}
+                               :field/optional true
+                               :field/type :text
+                               :field/placeholder {:en "en placeholder"
+                                                   :fi "fi placeholder"}}]}]
 
         (testing "invalid create"
           ;; TODO: silence the logging for this expected error
-          (let [command-with-invalid-maxlength (assoc-in command [:fields 0 :maxlength] -1)
+          (let [command-with-invalid-max-length (assoc-in command [:fields 0 :field/max-length] -1)
                 response (-> (request :post "/api/forms/create")
                              (authenticate api-key user-id)
-                             (json-body command-with-invalid-maxlength)
+                             (json-body command-with-invalid-max-length)
                              handler)]
             (is (= 400 (:status response))
-                "can't send negative maxlength")))
+                "can't send negative max length")))
 
         (testing "invalid create: field too long"
-          (let [command-with-long-prompt (assoc-in command [:fields 0 :input-prompt :en]
-                                                   (apply str (repeat 10000 "x")))
+          (let [command-with-long-placeholder (assoc-in command [:fields 0 :field/placeholder :en]
+                                                        (apply str (repeat 10000 "x")))
                 response (-> (request :post "/api/forms/create")
                              (authenticate api-key user-id)
-                             (json-body command-with-long-prompt)
+                             (json-body command-with-long-placeholder)
                              handler)]
             (is (= 500 (:status response)))))
 
@@ -69,7 +87,7 @@
                   (is (= (select-keys command [:title :organization])
                          (select-keys form-template [:title :organization])))
                   (is (= (:fields command)
-                         (mapv #(dissoc % :id) (:fields form-template)))))))))))))
+                         (mapv fixup-field-to-match-command (:fields form-template)))))))))))))
 
 (deftest forms-api-all-field-types-test
   (let [api-key "42"
@@ -77,39 +95,39 @@
         ;;"attachment" "date" "description" "label" "multiselect" "option" "text" "texta"
         localized {:en "en" :fi "fi"}
         form-spec {:organization "abc" :title "all field types test"
-                   :fields [{:type "text"
-                             :title localized
-                             :optional false}
-                            {:type "texta"
-                             :title localized
-                             :optional true
-                             :maxlength 300
-                             :input-prompt localized}
-                            {:type "description"
-                             :title localized
-                             :optional false}
-                            {:type "option"
-                             :title localized
-                             :optional true
-                             :options [{:key "a" :label localized}
-                                       {:key "b" :label localized}
-                                       {:key "c" :label localized}]}
-                            {:type "multiselect"
-                             :title localized
-                             :optional false
-                             :options [{:key "a" :label localized}
-                                       {:key "b" :label localized}
-                                       {:key "c" :label localized}
-                                       {:key "d" :label localized}]}
-                            {:type "label"
-                             :title localized
-                             :optional true}
-                            {:type "date"
-                             :title localized
-                             :optional true}
-                            {:type "attachment"
-                             :title localized
-                             :optional false}]}]
+                   :fields [{:field/type :text
+                             :field/title localized
+                             :field/optional false}
+                            {:field/type :texta
+                             :field/title localized
+                             :field/optional true
+                             :field/max-length 300
+                             :field/placeholder localized}
+                            {:field/type :description
+                             :field/title localized
+                             :field/optional false}
+                            {:field/type :option
+                             :field/title localized
+                             :field/optional true
+                             :field/options [{:key "a" :label localized}
+                                             {:key "b" :label localized}
+                                             {:key "c" :label localized}]}
+                            {:field/type :multiselect
+                             :field/title localized
+                             :field/optional false
+                             :field/options [{:key "a" :label localized}
+                                             {:key "b" :label localized}
+                                             {:key "c" :label localized}
+                                             {:key "d" :label localized}]}
+                            {:field/type :label
+                             :field/title localized
+                             :field/optional true}
+                            {:field/type :date
+                             :field/title localized
+                             :field/optional true}
+                            {:field/type :attachment
+                             :field/title localized
+                             :field/optional false}]}]
     (testing "creating"
       (let [form-id (-> (request :post "/api/forms/create")
                         (authenticate api-key user-id)
@@ -126,7 +144,7 @@
             (is (= (select-keys form-spec [:organization :title])
                    (select-keys form [:organization :title])))
             (is (= (:fields form-spec)
-                   (mapv #(dissoc % :id) (:fields form))))))))))
+                   (mapv fixup-field-to-match-command (:fields form))))))))))
 
 (deftest form-editable-test
   (let [api-key "42"
@@ -174,18 +192,18 @@
                      handler
                      read-ok-body)]
         (is (= (form :organization) "abc")))
-     (let [response (-> (request :put (str "/api/forms/" form-id "/edit"))
-                        (authenticate api-key user-id)
-                        (json-body {:organization "def" :title "form edit test"
-                                    :fields []})
-                        handler
-                        read-ok-body)]
-       (testing "form content after editing"
-         (let [form (-> (request :get (str "/api/forms/" form-id))
-                        (authenticate api-key user-id)
-                        handler
-                        read-ok-body)]
-           (is (= (form :organization) "def"))))))))
+      (let [response (-> (request :put (str "/api/forms/" form-id "/edit"))
+                         (authenticate api-key user-id)
+                         (json-body {:organization "def" :title "form edit test"
+                                     :fields []})
+                         handler
+                         read-ok-body)]
+        (testing "form content after editing"
+          (let [form (-> (request :get (str "/api/forms/" form-id))
+                         (authenticate api-key user-id)
+                         handler
+                         read-ok-body)]
+            (is (= (form :organization) "def"))))))))
 
 (deftest form-update-test
   (let [api-key "42"
@@ -235,16 +253,16 @@
     (testing "create"
       (let [command {:organization "abc"
                      :title (str "form title " (UUID/randomUUID))
-                     :fields [{:title {:en "en title"
-                                       :fi "fi title"}
-                               :optional true
-                               :type "option"
-                               :options [{:key "yes"
-                                          :label {:en "Yes"
-                                                  :fi "Kyllä"}}
-                                         {:key "no"
-                                          :label {:en "No"
-                                                  :fi "Ei"}}]}]}
+                     :fields [{:field/title {:en "en title"
+                                             :fi "fi title"}
+                               :field/optional true
+                               :field/type :option
+                               :field/options [{:key "yes"
+                                                :label {:en "Yes"
+                                                        :fi "Kyllä"}}
+                                               {:key "no"
+                                                :label {:en "No"
+                                                        :fi "Ei"}}]}]}
             id (-> (request :post "/api/forms/create")
                    (authenticate api-key user-id)
                    (json-body command)
@@ -258,7 +276,7 @@
                          handler
                          read-ok-body)]
             (is (= (:fields command)
-                   (mapv #(dissoc % :id) (:fields form))))))))))
+                   (mapv fixup-field-to-match-command (:fields form))))))))))
 
 (deftest forms-api-filtering-test
   (let [unfiltered (-> (request :get "/api/forms" {:archived true})
diff --git a/test/clj/rems/application/test_commands.clj b/test/clj/rems/application/test_commands.clj
index 2724007f3..c99a74777 100644
--- a/test/clj/rems/application/test_commands.clj
+++ b/test/clj/rems/application/test_commands.clj
@@ -1,6 +1,5 @@
 (ns rems.application.test-commands
-  (:require [clojure.string :as str]
-            [clojure.test :refer :all]
+  (:require [clojure.test :refer :all]
             [rems.application.commands :as commands]
             [rems.application.events :as events]
             [rems.application.model :as model]
@@ -26,11 +25,7 @@
                                     :workflow/id 1
                                     :workflow/type :workflow/dynamic})
 (def ^:private dummy-workflows {1 {:workflow {:handlers [handler-user-id]}}})
-
-(def ^:private dummy-forms {1 {:items [{:id 41
-                                        :optional false}
-                                       {:id 42
-                                        :optional false}]}})
+(def ^:private dummy-forms {1 {}})
 
 (def ^:private injections
   {:get-workflow dummy-workflows
diff --git a/test/clj/rems/application/test_model.clj b/test/clj/rems/application/test_model.clj
index 2327f5976..b1bf5fc80 100644
--- a/test/clj/rems/application/test_model.clj
+++ b/test/clj/rems/application/test_model.clj
@@ -11,20 +11,20 @@
   {40 {:id 40
        :organization "org"
        :title "form title"
-       :fields [{:id 41
-                 :title {:en "en title" :fi "fi title"}
-                 :input-prompt {:en "en placeholder" :fi "fi placeholder"}
-                 :optional false
-                 :options []
-                 :maxlength 100
-                 :type "description"}
-                {:id 42
-                 :title {:en "en title" :fi "fi title"}
-                 :input-prompt {:en "en placeholder" :fi "fi placeholder"}
-                 :optional false
-                 :options []
-                 :maxlength 100
-                 :type "text"}]
+       :fields [{:field/id 41
+                 :field/title {:en "en title" :fi "fi title"}
+                 :field/placeholder {:en "en placeholder" :fi "fi placeholder"}
+                 :field/optional false
+                 :field/options []
+                 :field/max-length 100
+                 :field/type :description}
+                {:field/id 42
+                 :field/title {:en "en title" :fi "fi title"}
+                 :field/placeholder {:en "en placeholder" :fi "fi placeholder"}
+                 :field/optional false
+                 :field/options []
+                 :field/max-length 100
+                 :field/type :text}]
        :start (DateTime. 100)
        :end nil}})
 
diff --git a/test/cljs/rems/administration/test_create_form.cljs b/test/cljs/rems/administration/test_create_form.cljs
index eb57bea49..8aee0c504 100644
--- a/test/cljs/rems/administration/test_create_form.cljs
+++ b/test/cljs/rems/administration/test_create_form.cljs
@@ -20,7 +20,7 @@
 
       (rf/dispatch-sync [::f/add-form-field])
 
-      (is (= {:fields [{:type "text"}]}
+      (is (= {:fields [{:field/type :text}]}
              @form)
           "after"))
 
@@ -28,13 +28,13 @@
       (reset-form)
       (rf/dispatch-sync [::f/add-form-field])
       (rf/dispatch-sync [::f/set-form-field [:fields 0 :foo] "old field"])
-      (is (= {:fields [{:type "text" :foo "old field"}]}
+      (is (= {:fields [{:field/type :text :foo "old field"}]}
              @form)
           "before")
 
       (rf/dispatch-sync [::f/add-form-field])
 
-      (is (= {:fields [{:type "text" :foo "old field"} {:type "text"}]}
+      (is (= {:fields [{:field/type :text :foo "old field"} {:field/type :text}]}
              @form)
           "after"))))
 
@@ -43,7 +43,7 @@
     (testing "removes fields"
       (reset-form)
       (rf/dispatch-sync [::f/add-form-field])
-      (is (= {:fields [{:type "text"}]}
+      (is (= {:fields [{:field/type :text}]}
              @form)
           "before")
 
@@ -61,16 +61,16 @@
       (rf/dispatch-sync [::f/set-form-field [:fields 0 :foo] "field 0"])
       (rf/dispatch-sync [::f/set-form-field [:fields 1 :foo] "field 1"])
       (rf/dispatch-sync [::f/set-form-field [:fields 2 :foo] "field 2"])
-      (is (= {:fields [{:type "text" :foo "field 0"}
-                      {:type "text" :foo "field 1"}
-                      {:type "text" :foo "field 2"}]}
+      (is (= {:fields [{:field/type :text :foo "field 0"}
+                       {:field/type :text :foo "field 1"}
+                       {:field/type :text :foo "field 2"}]}
              @form)
           "before")
 
       (rf/dispatch-sync [::f/remove-form-field 1])
 
-      (is (= {:fields [{:type "text" :foo "field 0"}
-                      {:type "text" :foo "field 2"}]}
+      (is (= {:fields [{:field/type :text :foo "field 0"}
+                       {:field/type :text :foo "field 2"}]}
              @form)
           "after"))))
 
@@ -84,34 +84,34 @@
       (rf/dispatch-sync [::f/set-form-field [:fields 0 :foo] "field 0"])
       (rf/dispatch-sync [::f/set-form-field [:fields 1 :foo] "field 1"])
       (rf/dispatch-sync [::f/set-form-field [:fields 2 :foo] "field X"])
-      (is (= {:fields [{:type "text" :foo "field 0"}
-                      {:type "text" :foo "field 1"}
-                      {:type "text" :foo "field X"}]}
+      (is (= {:fields [{:field/type :text :foo "field 0"}
+                       {:field/type :text :foo "field 1"}
+                       {:field/type :text :foo "field X"}]}
              @form)
           "before")
 
       (rf/dispatch-sync [::f/move-form-field-up 2])
 
-      (is (= {:fields [{:type "text" :foo "field 0"}
-                      {:type "text" :foo "field X"}
-                      {:type "text" :foo "field 1"}]}
+      (is (= {:fields [{:field/type :text :foo "field 0"}
+                       {:field/type :text :foo "field X"}
+                       {:field/type :text :foo "field 1"}]}
              @form)
           "after move 1")
 
       (rf/dispatch-sync [::f/move-form-field-up 1])
 
-      (is (= {:fields [{:type "text" :foo "field X"}
-                      {:type "text" :foo "field 0"}
-                      {:type "text" :foo "field 1"}]}
+      (is (= {:fields [{:field/type :text :foo "field X"}
+                       {:field/type :text :foo "field 0"}
+                       {:field/type :text :foo "field 1"}]}
              @form)
           "after move 2")
 
       (testing "unless already first"
         (rf/dispatch-sync [::f/move-form-field-up 0])
 
-        (is (= {:fields [{:type "text" :foo "field X"}
-                        {:type "text" :foo "field 0"}
-                        {:type "text" :foo "field 1"}]}
+        (is (= {:fields [{:field/type :text :foo "field X"}
+                         {:field/type :text :foo "field 0"}
+                         {:field/type :text :foo "field 1"}]}
                @form)
             "after move 3")))))
 
@@ -125,59 +125,59 @@
       (rf/dispatch-sync [::f/set-form-field [:fields 0 :foo] "field X"])
       (rf/dispatch-sync [::f/set-form-field [:fields 1 :foo] "field 1"])
       (rf/dispatch-sync [::f/set-form-field [:fields 2 :foo] "field 2"])
-      (is (= {:fields [{:type "text" :foo "field X"}
-                      {:type "text" :foo "field 1"}
-                      {:type "text" :foo "field 2"}]}
+      (is (= {:fields [{:field/type :text :foo "field X"}
+                       {:field/type :text :foo "field 1"}
+                       {:field/type :text :foo "field 2"}]}
              @form)
           "before")
 
       (rf/dispatch-sync [::f/move-form-field-down 0])
 
-      (is (= {:fields [{:type "text" :foo "field 1"}
-                      {:type "text" :foo "field X"}
-                      {:type "text" :foo "field 2"}]}
+      (is (= {:fields [{:field/type :text :foo "field 1"}
+                       {:field/type :text :foo "field X"}
+                       {:field/type :text :foo "field 2"}]}
              @form)
           "after move 1")
 
       (rf/dispatch-sync [::f/move-form-field-down 1])
 
-      (is (= {:fields [{:type "text" :foo "field 1"}
-                      {:type "text" :foo "field 2"}
-                      {:type "text" :foo "field X"}]}
+      (is (= {:fields [{:field/type :text :foo "field 1"}
+                       {:field/type :text :foo "field 2"}
+                       {:field/type :text :foo "field X"}]}
              @form)
           "after move 2")
 
       (testing "unless already last"
         (rf/dispatch-sync [::f/move-form-field-down 2])
 
-        (is (= {:fields [{:type "text" :foo "field 1"}
-                        {:type "text" :foo "field 2"}
-                        {:type "text" :foo "field X"}]}
+        (is (= {:fields [{:field/type :text :foo "field 1"}
+                         {:field/type :text :foo "field 2"}
+                         {:field/type :text :foo "field X"}]}
                @form)
             "after move 3")))))
 
 (deftest build-request-test
   (let [form {:organization "abc"
               :title "the title"
-              :fields [{:title {:en "en title"
-                                :fi "fi title"}
-                       :optional true
-                       :type "text"
-                       :maxlength "12"
-                       :input-prompt {:en "en prompt"
-                                      :fi "fi prompt"}}]}
+              :fields [{:field/title {:en "en title"
+                                      :fi "fi title"}
+                        :field/optional true
+                        :field/type :text
+                        :field/max-length "12"
+                        :field/placeholder {:en "en placeholder"
+                                            :fi "fi placeholder"}}]}
         languages [:en :fi]]
 
     (testing "basic form"
       (is (= {:organization "abc"
               :title "the title"
-              :fields [{:title {:en "en title"
-                                :fi "fi title"}
-                        :optional true
-                        :type "text"
-                        :maxlength 12
-                        :input-prompt {:en "en prompt"
-                                       :fi "fi prompt"}}]}
+              :fields [{:field/title {:en "en title"
+                                      :fi "fi title"}
+                        :field/optional true
+                        :field/type :text
+                        :field/max-length 12
+                        :field/placeholder {:en "en placeholder"
+                                            :fi "fi placeholder"}}]}
              (build-request form languages))))
 
     (testing "zero fields"
@@ -187,90 +187,90 @@
              (build-request (assoc-in form [:fields] []) languages))))
 
     (testing "date fields"
-      (let [form (assoc-in form [:fields 0 :type] "date")]
+      (let [form (assoc-in form [:fields 0 :field/type] :date)]
         (is (= {:organization "abc"
                 :title "the title"
-                :fields [{:title {:en "en title"
-                                  :fi "fi title"}
-                          :optional true
-                          :type "date"}]}
+                :fields [{:field/title {:en "en title"
+                                        :fi "fi title"}
+                          :field/optional true
+                          :field/type :date}]}
                (build-request form languages)))))
 
     (testing "missing optional implies false"
-      (is (false? (getx-in (build-request (assoc-in form [:fields 0 :optional] nil) languages)
-                           [:fields 0 :optional]))))
+      (is (false? (getx-in (build-request (assoc-in form [:fields 0 :field/optional] nil) languages)
+                           [:fields 0 :field/optional]))))
 
-    (testing "input prompt is optional"
+    (testing "placeholder is optional"
       (is (= {:en "" :fi ""}
-             (getx-in (build-request (assoc-in form [:fields 0 :input-prompt] nil) languages)
-                      [:fields 0 :input-prompt])
-             (getx-in (build-request (assoc-in form [:fields 0 :input-prompt] {:en ""}) languages)
-                      [:fields 0 :input-prompt])
-             (getx-in (build-request (assoc-in form [:fields 0 :input-prompt] {:en "" :fi ""}) languages)
-                      [:fields 0 :input-prompt]))))
-
-    (testing "maxlength is optional"
-      (is (nil? (getx-in (build-request (assoc-in form [:fields 0 :maxlength] "") languages)
-                         [:fields 0 :maxlength])))
-      (is (nil? (getx-in (build-request (assoc-in form [:fields 0 :maxlength] nil) languages)
-                         [:fields 0 :maxlength]))))
+             (getx-in (build-request (assoc-in form [:fields 0 :field/placeholder] nil) languages)
+                      [:fields 0 :field/placeholder])
+             (getx-in (build-request (assoc-in form [:fields 0 :field/placeholder] {:en ""}) languages)
+                      [:fields 0 :field/placeholder])
+             (getx-in (build-request (assoc-in form [:fields 0 :field/placeholder] {:en "" :fi ""}) languages)
+                      [:fields 0 :field/placeholder]))))
+
+    (testing "max length is optional"
+      (is (nil? (getx-in (build-request (assoc-in form [:fields 0 :field/max-length] "") languages)
+                         [:fields 0 :field/max-length])))
+      (is (nil? (getx-in (build-request (assoc-in form [:fields 0 :field/max-length] nil) languages)
+                         [:fields 0 :field/max-length]))))
 
     (testing "option fields"
       (let [form (-> form
-                     (assoc-in [:fields 0 :type] "option")
-                     (assoc-in [:fields 0 :options] [{:key "yes"
-                                                      :label {:en "en yes"
-                                                              :fi "fi yes"}}
-                                                     {:key "no"
-                                                      :label {:en "en no"
-                                                              :fi "fi no"}}]))]
+                     (assoc-in [:fields 0 :field/type] :option)
+                     (assoc-in [:fields 0 :field/options] [{:key "yes"
+                                                            :label {:en "en yes"
+                                                                    :fi "fi yes"}}
+                                                           {:key "no"
+                                                            :label {:en "en no"
+                                                                    :fi "fi no"}}]))]
         (is (= {:organization "abc"
                 :title "the title"
-                :fields [{:title {:en "en title"
-                                  :fi "fi title"}
-                          :optional true
-                          :type "option"
-                          :options [{:key "yes"
-                                     :label {:en "en yes"
-                                             :fi "fi yes"}}
-                                    {:key "no"
-                                     :label {:en "en no"
-                                             :fi "fi no"}}]}]}
+                :fields [{:field/title {:en "en title"
+                                        :fi "fi title"}
+                          :field/optional true
+                          :field/type :option
+                          :field/options [{:key "yes"
+                                           :label {:en "en yes"
+                                                   :fi "fi yes"}}
+                                          {:key "no"
+                                           :label {:en "en no"
+                                                   :fi "fi no"}}]}]}
                (build-request form languages)))))
 
     (testing "multiselect fields"
       (let [form (-> form
-                     (assoc-in [:fields 0 :type] "multiselect")
-                     (assoc-in [:fields 0 :options] [{:key "egg"
-                                                      :label {:en "Egg"
-                                                              :fi "Munaa"}}
-                                                     {:key "bacon"
-                                                      :label {:en "Bacon"
-                                                              :fi "Pekonia"}}]))]
+                     (assoc-in [:fields 0 :field/type] :multiselect)
+                     (assoc-in [:fields 0 :field/options] [{:key "egg"
+                                                            :label {:en "Egg"
+                                                                    :fi "Munaa"}}
+                                                           {:key "bacon"
+                                                            :label {:en "Bacon"
+                                                                    :fi "Pekonia"}}]))]
         (is (= {:organization "abc"
                 :title "the title"
-                :fields [{:title {:en "en title"
-                                  :fi "fi title"}
-                          :optional true
-                          :type "multiselect"
-                          :options [{:key "egg"
-                                     :label {:en "Egg"
-                                             :fi "Munaa"}}
-                                    {:key "bacon"
-                                     :label {:en "Bacon"
-                                             :fi "Pekonia"}}]}]}
+                :fields [{:field/title {:en "en title"
+                                        :fi "fi title"}
+                          :field/optional true
+                          :field/type :multiselect
+                          :field/options [{:key "egg"
+                                           :label {:en "Egg"
+                                                   :fi "Munaa"}}
+                                          {:key "bacon"
+                                           :label {:en "Bacon"
+                                                   :fi "Pekonia"}}]}]}
                (build-request form languages)))))))
 
 (deftest validate-form-test
   (let [form {:organization "abc"
               :title "the title"
-              :fields [{:title {:en "en title"
-                                :fi "fi title"}
-                       :optional true
-                       :type "text"
-                       :maxlength "12"
-                       :input-prompt {:en "en prompt"
-                                      :fi "fi prompt"}}]}
+              :fields [{:field/title {:en "en title"
+                                      :fi "fi title"}
+                        :field/optional true
+                        :field/type :text
+                        :field/max-length "12"
+                        :field/placeholder {:en "en placeholder"
+                                            :fi "fi placeholder"}}]}
         languages [:en :fi]]
 
     (testing "valid form"
@@ -288,81 +288,81 @@
       (is (empty? (validate-form (assoc-in form [:fields] []) languages))))
 
     (testing "missing field title"
-      (let [nil-title (validate-form (assoc-in form [:fields 0 :title] nil) languages)]
-        (is (= (get-in (validate-form (assoc-in form [:fields 0 :title :en] "") languages)
-                       [:fields 0 :title :en])
-               (get-in (validate-form (update-in form [:fields 0 :title] dissoc :en) languages)
-                       [:fields 0 :title :en])
-               (get-in nil-title [:fields 0 :title :en])
-               (get-in nil-title [:fields 0 :title :fi])
+      (let [nil-title (validate-form (assoc-in form [:fields 0 :field/title] nil) languages)]
+        (is (= (get-in (validate-form (assoc-in form [:fields 0 :field/title :en] "") languages)
+                       [:fields 0 :field/title :en])
+               (get-in (validate-form (update-in form [:fields 0 :field/title] dissoc :en) languages)
+                       [:fields 0 :field/title :en])
+               (get-in nil-title [:fields 0 :field/title :en])
+               (get-in nil-title [:fields 0 :field/title :fi])
                :t.form.validation/required))))
 
     (testing "missing field type"
-      (is (get-in (validate-form (assoc-in form [:fields 0 :type] nil) language)
-                  [:fields 0 :type])
+      (is (get-in (validate-form (assoc-in form [:fields 0 :field/type] nil) languages)
+                  [:fields 0 :field/type])
           :t.form.validation/required))
 
-    (testing "if you use input prompt, you must fill in all the languages"
-      (is (= (get-in (validate-form (assoc-in form [:fields 0 :input-prompt] {:en "en prompt" :fi ""}) languages)
-                     [:fields 0 :input-prompt :fi])
-             (get-in (validate-form (assoc-in form [:fields 0 :input-prompt] {:en "en prompt"}) languages)
-                     [:fields 0 :input-prompt :fi])
+    (testing "if you use a placeholder, you must fill in all the languages"
+      (is (= (get-in (validate-form (assoc-in form [:fields 0 :field/placeholder] {:en "en placeholder" :fi ""}) languages)
+                     [:fields 0 :field/placeholder :fi])
+             (get-in (validate-form (assoc-in form [:fields 0 :field/placeholder] {:en "en placeholder"}) languages)
+                     [:fields 0 :field/placeholder :fi])
              :t.form.validation/required)))
 
     (testing "option fields"
       (let [form (-> form
-                     (assoc-in [:fields 0 :type] "option")
-                     (assoc-in [:fields 0 :options] [{:key "yes"
-                                                      :label {:en "en yes"
-                                                              :fi "fi yes"}}
-                                                     {:key "no"
-                                                      :label {:en "en no"
-                                                              :fi "fi no"}}]))]
+                     (assoc-in [:fields 0 :field/type] :option)
+                     (assoc-in [:fields 0 :field/options] [{:key "yes"
+                                                            :label {:en "en yes"
+                                                                    :fi "fi yes"}}
+                                                           {:key "no"
+                                                            :label {:en "en no"
+                                                                    :fi "fi no"}}]))]
         (testing "valid form"
           (is (empty? (validate-form form languages))))
 
         (testing "missing option key"
-          (is (= (get-in (validate-form (assoc-in form [:fields 0 :options 0 :key] "") languages)
-                         [:fields 0 :options 0 :key])
-                 (get-in (validate-form (assoc-in form [:fields 0 :options 0 :key] nil) languages)
-                         [:fields 0 :options 0 :key])
+          (is (= (get-in (validate-form (assoc-in form [:fields 0 :field/options 0 :key] "") languages)
+                         [:fields 0 :field/options 0 :key])
+                 (get-in (validate-form (assoc-in form [:fields 0 :field/options 0 :key] nil) languages)
+                         [:fields 0 :field/options 0 :key])
                  :t.form.validation/required)))
 
         (testing "missing option label"
-          (let [empty-label (validate-form (assoc-in form [:fields 0 :options 0 :label] {:en "" :fi ""}) languages)
-                nil-label (validate-form (assoc-in form [:fields 0 :options 0 :label] nil) languages)]
-            (is (= (get-in empty-label [:fields 0 :options 0 :label :en])
-                   (get-in empty-label [:fields 0 :options 0 :label :fi])
-                   (get-in nil-label [:fields 0 :options 0 :label :en])
-                   (get-in nil-label [:fields 0 :options 0 :label :fi])
+          (let [empty-label (validate-form (assoc-in form [:fields 0 :field/options 0 :label] {:en "" :fi ""}) languages)
+                nil-label (validate-form (assoc-in form [:fields 0 :field/options 0 :label] nil) languages)]
+            (is (= (get-in empty-label [:fields 0 :field/options 0 :label :en])
+                   (get-in empty-label [:fields 0 :field/options 0 :label :fi])
+                   (get-in nil-label [:fields 0 :field/options 0 :label :en])
+                   (get-in nil-label [:fields 0 :field/options 0 :label :fi])
                    :t.form.validation/required))))))
 
     (testing "multiselect fields"
       (let [form (-> form
-                     (assoc-in [:fields 0 :type] "multiselect")
-                     (assoc-in [:fields 0 :options] [{:key "egg"
-                                                      :label {:en "Egg"
-                                                              :fi "Munaa"}}
-                                                     {:key "bacon"
-                                                      :label {:en "Bacon"
-                                                              :fi "Pekonia"}}]))]
+                     (assoc-in [:fields 0 :field/type] :multiselect)
+                     (assoc-in [:fields 0 :field/options] [{:key "egg"
+                                                            :label {:en "Egg"
+                                                                    :fi "Munaa"}}
+                                                           {:key "bacon"
+                                                            :label {:en "Bacon"
+                                                                    :fi "Pekonia"}}]))]
         (testing "valid form"
           (is (empty? (validate-form form languages))))
 
         (testing "missing option key"
-          (is (= (get-in (validate-form (assoc-in form [:fields 0 :options 0 :key] "") languages)
-                         [:fields 0 :options 0 :key])
-                 (get-in (validate-form (assoc-in form [:fields 0 :options 0 :key] nil) languages)
-                         [:fields 0 :options 0 :key])
+          (is (= (get-in (validate-form (assoc-in form [:fields 0 :field/options 0 :key] "") languages)
+                         [:fields 0 :field/options 0 :key])
+                 (get-in (validate-form (assoc-in form [:fields 0 :field/options 0 :key] nil) languages)
+                         [:fields 0 :field/options 0 :key])
                  :t.form.validation/required)))
 
         (testing "missing option label"
-          (let [empty-label (validate-form (assoc-in form [:fields 0 :options 0 :label] {:en "" :fi ""}) languages)
-                nil-label (validate-form (assoc-in form [:fields 0 :options 0 :label] nil) languages)]
-            (is (= (get-in empty-label [:fields 0 :options 0 :label :en])
-                   (get-in empty-label [:fields 0 :options 0 :label :fi])
-                   (get-in nil-label [:fields 0 :options 0 :label :en])
-                   (get-in nil-label [:fields 0 :options 0 :label :fi])
+          (let [empty-label (validate-form (assoc-in form [:fields 0 :field/options 0 :label] {:en "" :fi ""}) languages)
+                nil-label (validate-form (assoc-in form [:fields 0 :field/options 0 :label] nil) languages)]
+            (is (= (get-in empty-label [:fields 0 :field/options 0 :label :en])
+                   (get-in empty-label [:fields 0 :field/options 0 :label :fi])
+                   (get-in nil-label [:fields 0 :field/options 0 :label :en])
+                   (get-in nil-label [:fields 0 :field/options 0 :label :fi])
                    :t.form.validation/required))))))))
 
 (deftest build-localized-string-test