UI component hidden input on checkout addressDisplay a custom field with Rendered in Product Grid UI Component in Magento 2Checkout uiComponent (input field) rendered multiple times: how do I apply viewmodel functionality to current input field only?Magento 2 - insertListing ui componentDynamically hide component upon selecting a country in checkoutMagento 2: Override city on CheckoutMagento 2 How to change event of postcode in customer checkout address form?M2 Add fields to custom payment method [ship to multiple address]Problem when validating city field when registering new address at checkout M2Change value of text field in admin form based on option selected in dropdownRender fields base on attributes to system.xml
Why does the Trade Federation become so alarmed upon learning the ambassadors are Jedi Knights?
Align by center of symbol
If I stood next to a piece of metal heated to a million degrees, but in a perfect vacuum, would I feel hot?
Why hasn't the U.S. government paid war reparations to any country it attacked?
Mathematica function equivalent to Matlab's residue function (partial fraction expansion)
Is dividends exclusively a part of earnings?
Old short story where the future emperor of the galaxy is taken for a tour around Earth
Why use null function instead of == [] to check for empty list in Haskell?
Diminished chord constructed over the tonic degree?
I quit, and boss offered me 3 month "grace period" where I could still come back
Can a British citizen travel with a Nigerian passport?
When to ask for constructive criticism?
What to look for in climbing shoes?
What's the phrasal verb for carbonated drinks exploding out of the can after being shaken?
Is there a way to handmake alphabet pasta?
What do mathematicians mean when they say some conjecture can’t be proven using the current technology?
What is the superlative of ipse?
Why did Spider-Man take a detour to Dorset?
What is this old "lemon-squeezer" shaped pan
What are the arguments for California’s nonpartisan blanket primaries?
Construct a pentagon avoiding compass use
Using two linked programs, output ordinal numbers up to n
Can I send medicine to someone in Canada?
Why do legislative committees exist?
UI component hidden input on checkout address
Display a custom field with Rendered in Product Grid UI Component in Magento 2Checkout uiComponent (input field) rendered multiple times: how do I apply viewmodel functionality to current input field only?Magento 2 - insertListing ui componentDynamically hide component upon selecting a country in checkoutMagento 2: Override city on CheckoutMagento 2 How to change event of postcode in customer checkout address form?M2 Add fields to custom payment method [ship to multiple address]Problem when validating city field when registering new address at checkout M2Change value of text field in admin form based on option selected in dropdownRender fields base on attributes to system.xml
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am adding custom field on Magento 2 checkout shipping address.
It's a hidden input.
The value should be automatically updated based on another custom field which is a select (populated from ajax response data), using its option text/label.
How can I "link" between input value and selected option text?
In my current custom component for the select, it already export the value to input
exports:
value: '$ $.provider :shippingAddress.custom_attributes.subdstrict:value'
But it sends the selected value instead of the text. how to send the selected option text instead?
magento2
add a comment |
I am adding custom field on Magento 2 checkout shipping address.
It's a hidden input.
The value should be automatically updated based on another custom field which is a select (populated from ajax response data), using its option text/label.
How can I "link" between input value and selected option text?
In my current custom component for the select, it already export the value to input
exports:
value: '$ $.provider :shippingAddress.custom_attributes.subdstrict:value'
But it sends the selected value instead of the text. how to send the selected option text instead?
magento2
add a comment |
I am adding custom field on Magento 2 checkout shipping address.
It's a hidden input.
The value should be automatically updated based on another custom field which is a select (populated from ajax response data), using its option text/label.
How can I "link" between input value and selected option text?
In my current custom component for the select, it already export the value to input
exports:
value: '$ $.provider :shippingAddress.custom_attributes.subdstrict:value'
But it sends the selected value instead of the text. how to send the selected option text instead?
magento2
I am adding custom field on Magento 2 checkout shipping address.
It's a hidden input.
The value should be automatically updated based on another custom field which is a select (populated from ajax response data), using its option text/label.
How can I "link" between input value and selected option text?
In my current custom component for the select, it already export the value to input
exports:
value: '$ $.provider :shippingAddress.custom_attributes.subdstrict:value'
But it sends the selected value instead of the text. how to send the selected option text instead?
magento2
magento2
edited Oct 18 '17 at 7:43
Teja Bhagavan Kollepara
3,0144 gold badges21 silver badges51 bronze badges
3,0144 gold badges21 silver badges51 bronze badges
asked Oct 18 '17 at 3:57
Doni WibowoDoni Wibowo
1152 silver badges13 bronze badges
1152 silver badges13 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I managed to achieve this using this code
return Select.extend(
defaults:
skipValidation: false,
exports:
// Don: any change to subdisrict_id dropdown will "send" notifcation to subdistrict input
selectedSubdistrictName: '$ $.provider :$ $.customScope .custom_attributes.subdistrict:value'
,
/**
* @inheritdoc
*/
initObservable: function ()
this._super()
.observe(['selectedSubdistrictName']);
return this;
,
/**
* Filters 'initialOptions' property by 'field' and 'value' passed,
* calls 'setOptions' passing the result to it
*
* @param * value
* @param String field
*/
initialize : function()
var self = this;
this._super();
self.value.subscribe(function(value)
self.selectedSubdistrictName( self.getPreview() );
, this)
,
filter: function (value, field)
if(value)
var thisField = this;
$.ajax(
type: 'GET',
url: '/rest/V1/fabelio-directory/subdistricts/' + value,
dataType: 'json',
success: function(data)
// rename keys
var options = [];
var option = ;
for(var i = 0; i < data.length; i++)
option =
'value': data[i].subdistrict_id,
'label': data[i].name
;
options.push(option);
thisField.setOptions(options);
,
error: function()
,
complete: function()
);
);
});
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f197683%2fui-component-hidden-input-on-checkout-address%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I managed to achieve this using this code
return Select.extend(
defaults:
skipValidation: false,
exports:
// Don: any change to subdisrict_id dropdown will "send" notifcation to subdistrict input
selectedSubdistrictName: '$ $.provider :$ $.customScope .custom_attributes.subdistrict:value'
,
/**
* @inheritdoc
*/
initObservable: function ()
this._super()
.observe(['selectedSubdistrictName']);
return this;
,
/**
* Filters 'initialOptions' property by 'field' and 'value' passed,
* calls 'setOptions' passing the result to it
*
* @param * value
* @param String field
*/
initialize : function()
var self = this;
this._super();
self.value.subscribe(function(value)
self.selectedSubdistrictName( self.getPreview() );
, this)
,
filter: function (value, field)
if(value)
var thisField = this;
$.ajax(
type: 'GET',
url: '/rest/V1/fabelio-directory/subdistricts/' + value,
dataType: 'json',
success: function(data)
// rename keys
var options = [];
var option = ;
for(var i = 0; i < data.length; i++)
option =
'value': data[i].subdistrict_id,
'label': data[i].name
;
options.push(option);
thisField.setOptions(options);
,
error: function()
,
complete: function()
);
);
});
add a comment |
I managed to achieve this using this code
return Select.extend(
defaults:
skipValidation: false,
exports:
// Don: any change to subdisrict_id dropdown will "send" notifcation to subdistrict input
selectedSubdistrictName: '$ $.provider :$ $.customScope .custom_attributes.subdistrict:value'
,
/**
* @inheritdoc
*/
initObservable: function ()
this._super()
.observe(['selectedSubdistrictName']);
return this;
,
/**
* Filters 'initialOptions' property by 'field' and 'value' passed,
* calls 'setOptions' passing the result to it
*
* @param * value
* @param String field
*/
initialize : function()
var self = this;
this._super();
self.value.subscribe(function(value)
self.selectedSubdistrictName( self.getPreview() );
, this)
,
filter: function (value, field)
if(value)
var thisField = this;
$.ajax(
type: 'GET',
url: '/rest/V1/fabelio-directory/subdistricts/' + value,
dataType: 'json',
success: function(data)
// rename keys
var options = [];
var option = ;
for(var i = 0; i < data.length; i++)
option =
'value': data[i].subdistrict_id,
'label': data[i].name
;
options.push(option);
thisField.setOptions(options);
,
error: function()
,
complete: function()
);
);
});
add a comment |
I managed to achieve this using this code
return Select.extend(
defaults:
skipValidation: false,
exports:
// Don: any change to subdisrict_id dropdown will "send" notifcation to subdistrict input
selectedSubdistrictName: '$ $.provider :$ $.customScope .custom_attributes.subdistrict:value'
,
/**
* @inheritdoc
*/
initObservable: function ()
this._super()
.observe(['selectedSubdistrictName']);
return this;
,
/**
* Filters 'initialOptions' property by 'field' and 'value' passed,
* calls 'setOptions' passing the result to it
*
* @param * value
* @param String field
*/
initialize : function()
var self = this;
this._super();
self.value.subscribe(function(value)
self.selectedSubdistrictName( self.getPreview() );
, this)
,
filter: function (value, field)
if(value)
var thisField = this;
$.ajax(
type: 'GET',
url: '/rest/V1/fabelio-directory/subdistricts/' + value,
dataType: 'json',
success: function(data)
// rename keys
var options = [];
var option = ;
for(var i = 0; i < data.length; i++)
option =
'value': data[i].subdistrict_id,
'label': data[i].name
;
options.push(option);
thisField.setOptions(options);
,
error: function()
,
complete: function()
);
);
});
I managed to achieve this using this code
return Select.extend(
defaults:
skipValidation: false,
exports:
// Don: any change to subdisrict_id dropdown will "send" notifcation to subdistrict input
selectedSubdistrictName: '$ $.provider :$ $.customScope .custom_attributes.subdistrict:value'
,
/**
* @inheritdoc
*/
initObservable: function ()
this._super()
.observe(['selectedSubdistrictName']);
return this;
,
/**
* Filters 'initialOptions' property by 'field' and 'value' passed,
* calls 'setOptions' passing the result to it
*
* @param * value
* @param String field
*/
initialize : function()
var self = this;
this._super();
self.value.subscribe(function(value)
self.selectedSubdistrictName( self.getPreview() );
, this)
,
filter: function (value, field)
if(value)
var thisField = this;
$.ajax(
type: 'GET',
url: '/rest/V1/fabelio-directory/subdistricts/' + value,
dataType: 'json',
success: function(data)
// rename keys
var options = [];
var option = ;
for(var i = 0; i < data.length; i++)
option =
'value': data[i].subdistrict_id,
'label': data[i].name
;
options.push(option);
thisField.setOptions(options);
,
error: function()
,
complete: function()
);
);
});
answered Oct 19 '17 at 6:15
Doni WibowoDoni Wibowo
1152 silver badges13 bronze badges
1152 silver badges13 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f197683%2fui-component-hidden-input-on-checkout-address%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown