File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -137,10 +137,15 @@ const options: VideomailClientOptions = {
137137
138138 callbacks : {
139139 /*
140- * a custom callback to tweak form data before posting to server
140+ * A custom callback to tweak form data before posting to server
141141 * this is for advanced use only and shouldn't be used if possible
142142 */
143143 adjustFormDataBeforePosting : undefined ,
144+
145+ /*
146+ Another custom callback to tweak a single form value before populating the form.
147+ */
148+ adjustFormValueBeforePopulating : undefined ,
144149 } ,
145150
146151 defaults : {
Original file line number Diff line number Diff line change 11import { PartialDeep } from "type-fest" ;
22
3- import { PartialVideomail } from "./Videomail" ;
3+ import { PartialVideomail , Videomail } from "./Videomail" ;
44
55export interface VideomailClientOptions {
66 logger : {
@@ -118,6 +118,9 @@ export interface VideomailClientOptions {
118118 adjustFormDataBeforePosting ?:
119119 | undefined
120120 | ( ( videomail : PartialVideomail ) => PartialVideomail ) ;
121+ adjustFormValueBeforePopulating ?:
122+ | undefined
123+ | ( ( name : string , videomail : Videomail ) => string ) ;
121124 } ;
122125
123126 defaults : {
Original file line number Diff line number Diff line change @@ -114,9 +114,13 @@ class Form extends Despot {
114114 const name = formControl . getAttribute ( "name" ) ;
115115
116116 if ( name ) {
117- const value = videomail [ name ] ;
117+ let value = videomail [ name ] ;
118118 const tagName = formControl . tagName ;
119119
120+ if ( this . options . callbacks . adjustFormValueBeforePopulating ) {
121+ value = this . options . callbacks . adjustFormValueBeforePopulating ( name , videomail ) ;
122+ }
123+
120124 switch ( tagName ) {
121125 case "INPUT" : {
122126 const inputControl = formControl as HTMLInputElement ;
You can’t perform that action at this time.
0 commit comments