How to show dropdown options from database like post category

We want to drop down addon select box from a database like city or company name in sepreate table.
I have created select box with data base but issue is when new entry in data base added then reflected in drop down but in post category working fine.
can any one help script is below

class GF_Field_Mselect extends GF_Field_Select {
    public $type = 'mselect';
	public function get_form_editor_field_title() {

	    return esc_attr__( 'Manager List', 'gravityforms' );
	public function get_form_editor_button() {
	    return array(
	        'group' => 'advanced_fields',
	        'text'  => $this->get_form_editor_field_title()

	 function get_form_editor_field_settings() {
     return array(



	public function is_conditional_logic_supported() {
    return true;

	 * The scripts to be included in the form editor.
	 * @return string
	    public function get_form_editor_inline_script_on_page_render() {
	    //Accessing data from manager table	

		global $wpdb;$mp='';

		// table 
	    $table_name = $wpdb->prefix . "vm_manager";   
	    $api = $wpdb->get_results( "SELECT * FROM $table_name where is_active=1 ");

	    foreach($api as $apiData){

	    $mp.= "new Choice('$apiData->name'),";

		//echo '<pre>';print_r($api);echo '<br>'; 
		$mlist = $mp;//combine the list of manger from API 
		//js for drop down
    	$script = sprintf( "function SetDefaultValues_mselect(field) { 
    	field.label = 'Manager List';
        field.choices = [ $mlist ];}", $this->get_form_editor_field_title() ) . PHP_EOL;  
		// initialize the fields custom settings
		$script .= "jQuery(document).bind('gform_load_field_settings', function (event, field, form) {" .
		           "var inputClass = field.inputClass == undefined ? '' : field.inputClass;" .
		           "jQuery('#input_class_setting').val(inputClass);" .
		           "});" . PHP_EOL;

		// saving the simple setting
		$script .= "function SetInputClassSetting(value) {SetFieldProperty('inputClass', value);}" . PHP_EOL;
		return $script;


 GF_Fields::register( new GF_Field_Mselect() );

HI Sandeep, Populate Anything might be an easier way to accomplish this kind of dynamic population. It supports populating from any table in your WordPress database (including custom tables and views).

Here’s a link to our comperhensive documentation but let me know if you have any implementation questions. :slightly_smiling_face:

1 Like

can we pass condition with table like show only active user list