Tag Archives: Disable

Lock, Disable Selection

In the event that you need to lock certain selections so that they can’t be removed, you can now pass in “locked” => true when calling set_init_selection(). Note that lock a selection is only possible when multiple selection is enabled.

To disable a selection from selected in the dropdown, add “disabled”=>true to the data source.

In the following example, the selection “Microsoft” is disabled.

$data = array(array('id'=>1, 'text'=>'Apple'),
    array('id'=>2, 'text'=>'Google'),
    array('id'=>3, 'text'=>'Microsoft', 'disabled'=>true),
    array('id'=>4, 'text'=>'Facebook'),
    array('id'=>5, 'text'=>'Twitter'));

$pac = new C_PhpAutocomplete('lock_selection_INPUT', $data);
$pac->enable_multiple(true);    // hidden input only
    array("id"=>"1", "text"=>"Apple"),
    array("id"=>"5", "text"=>"Twitter", "locked"=>true)));
<input id="lock_selection_INPUT" type="hidden" value="" />


Disable search. This essentially removes the search from the dropdown. Disable search makes the control looks like a regular dropdown.

Note that when either set_max_input_length() or set_min_input_length() method is presented, disable_search() is ignored.


public function disable_search()