Last active
November 23, 2020 23:57
-
-
Save obiPlabon/15c8ed8444b952dc7bf398d0219219c7 to your computer and use it in GitHub Desktop.
Elementor snippet to get the option name from a repeater select field by passing option key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
'title_field' => "<# | |
// This snippet doesn't ensure that it won't throw any error if there's no row/repeater item | |
// Make sure to check that | |
// First get the repeater control | |
var repeaterControl = elementor.getPanelView().getCurrentPageView().children.find(function(view) { | |
return view.model.get('name') === 'staffs'; | |
}), | |
// Get the first row from repeater | |
firstRow = repeaterControl.children.findByIndex(0), | |
// Get the title | |
// Use staff_id instead of id, id is used in elementor internally | |
// and may cause unexpected issues | |
title = firstRow.model.controls.staff_id.options[ staff_id ]; | |
print(title); | |
#>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
'title_field' => "<# | |
// This snippet doesn't ensure that it won't throw any error if there's no row/repeater item | |
// Make sure to check that | |
// First get the repeater control | |
var repeaterControl = elementor.getPanelView().getCurrentPageView().children.find(function(view) { | |
return view.model.get('name') === 'repeater_control_id_goes_here'; | |
}), | |
// Get the first row from repeater | |
firstRow = repeaterControl.children.findByIndex(0), | |
// Get the title by passing the | |
// ** Select control id goes here without the curly braces | |
title = firstRow.model.controls.{**}.options[{**}]; | |
print(title); | |
#>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment