Skip to content

Commit a4c771c

Browse files
authored
Enhancement: Create new options when editing a fields value on Selector. (#179)
* Migrate select fields php part * Add JS part
1 parent c596a74 commit a4c771c

File tree

3 files changed

+171
-95
lines changed

3 files changed

+171
-95
lines changed

assets/src/js/_acf-field-select.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
multiple: this.get( 'multiple' ),
3838
placeholder: this.get( 'placeholder' ),
3939
allowNull: this.get( 'allow_null' ),
40+
tags: this.get( 'create_options' ),
4041
ajaxAction: ajaxAction,
4142
} );
4243
}

assets/src/js/_acf-select2.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
multiple: false,
2020
field: false,
2121
ajax: false,
22+
tags: false,
2223
ajaxAction: '',
2324
ajaxData: function ( data ) {
2425
return data;
@@ -220,7 +221,6 @@
220221
if ( field.get( 'nonce' ) ) {
221222
ajaxData.nonce = field.get( 'nonce' );
222223
}
223-
224224
}
225225

226226
// callback
@@ -324,6 +324,11 @@
324324
data: [],
325325
};
326326

327+
if ( this.get( 'tags' ) ) {
328+
options.tags = true;
329+
options.tokenSeparators = [ ',' ];
330+
}
331+
327332
// Clear empty templateSelections, templateResults, or dropdownCssClass.
328333
if ( ! options.templateSelection ) {
329334
delete options.templateSelection;

0 commit comments

Comments
 (0)