File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ Function
112112 = 'setFieldValue' _ '(' _ target :PATH _ ',' _ source :SOURCEARG _ ')' {
113113 return {_funcName: ' setFieldValue' , _funcArgs: [target .split (' .' ), source]};
114114 }
115+ / 'setExtraData' _ '(' _ target :PATH _ ',' _ source :SOURCEARG _ ')' {
116+ return {_funcName: ' setExtraData' , _funcArgs: [target .split (' .' ), source]};
117+ }
115118 / 'deletePartial' _ '(' _ target :PATH _ ',' _ source :SOURCEARG _ ')' {
116119 return {_funcName: ' deletePartial' , _funcArgs: [target .split (' .' ), source]};
117120 }
Original file line number Diff line number Diff line change @@ -946,6 +946,17 @@ class DjangoButton {
946946 }
947947 }
948948
949+ /**
950+ * Transfer value from one element to another one.
951+ */
952+ //@allowedAction
953+ private setExtraData ( target : Path , source : FieldValue ) {
954+ return ( response : Response ) => {
955+ this . formset . setExtraData ( target , source ) ;
956+ return Promise . resolve ( response ) ;
957+ }
958+ }
959+
949960 //@allowedAction
950961 private deletePartial ( target : Path , source : FieldValue ) {
951962 return ( response : Response ) => {
@@ -2327,6 +2338,10 @@ export class DjangoFormset implements DjangoFormset {
23272338 }
23282339 }
23292340
2341+ public setExtraData ( path : Path , value : any ) {
2342+ setDataValue ( this . extraData , path , value ) ;
2343+ }
2344+
23302345 public findFirstErrorReport ( ) : Element | null {
23312346 for ( const form of this . forms ) {
23322347 const errorReportElement = form . findFirstErrorReport ( ) ;
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ as queued actions for buttons in **django-formset**:
100100 the latter case that value is transferred to the target field.
101101 By prefixing the source value with a ``^ `` caret, the value is taken from a response object
102102 fetched by a previous request.
103+ * ``setExtraData(path.to.target, source_value) `` sets a value to be submitted as extra data along
104+ with the form data. The target path specifies where to store that value inside the extra data
105+ object. The source value can be a string, number or a boolean. By prefixing the source value with
106+ a ``^ `` caret, the value is taken from a response object fetched by a previous request.
103107* ``emit("event name") `` emit a named event to the DOM.
104108* ``clearErrors `` clears all error annotations from a previously failed form validation.
105109* ``activate `` activates the button to be intercepted by another component, for instance in
You can’t perform that action at this time.
0 commit comments