Class AutoCompleteCustomFieldType
Defines the auto-complete field type.
Field Type Specific Arguments
settings
- (array|string) the first parameter value passed to thetokenInput()
jQuery plugin method.settings2
- (array) the second parameter value passed to thetokenInput()
jQuery plugin method.
Example
array( 'type' => 'autocomplete', 'field_id' => 'autocomplete_field', 'title' => __( 'Default', 'admin-page-framework-field-type-pack' ), 'description' => __( 'By default, all the post titles will be fetched in the background and will pop up.', 'admin-page-framework-field-type-pack' ), ), array( 'type' => 'autocomplete', 'field_id' => 'autocomplete_local_data', 'title' => __( 'Local Data', 'admin-page-framework-field-type-pack' ), 'settings' => array( array( 'id' => 7, 'name' => 'Ruby' ), array( 'id' => 11, 'name' => 'Python' ), array( 'id' => 13, 'name' => 'JavaScript' ), array( 'id' => 17, 'name' => 'ActionScript' ), array( 'id' => 19, 'name' => 'Scheme' ), array( 'id' => 23, 'name' => 'Lisp' ), array( 'id' => 29, 'name' => 'C#' ), array( 'id' => 31, 'name' => 'Fortran' ), array( 'id' => 37, 'name' => 'Visual Basic' ), array( 'id' => 41, 'name' => 'C' ), array( 'id' => 43, 'name' => 'C++' ), array( 'id' => 47, 'name' => 'Java' ), ), 'settings2' => array( 'theme' => 'mac', 'hintText' => __( 'Type a programming language.', 'admin-page-framework-field-type-pack' ), 'prePopulate' => array( array( 'id' => 3, 'name' => 'PHP' ), array( 'id' => 5, 'name' => 'APS' ), ) ), 'description' => __( 'Predefined items are Ruby, Python, JavaScript, ActionScript, Scheme, Lisp, C#, Fortran, Vidual Basic, C, C++, Java.', 'admin-page-framework-field-type-pack' ), ), array( 'type' => 'autocomplete', 'field_id' => 'autocomplete_custom_post_type', 'title' => __( 'Custom Post Type', 'admin-page-framework-field-type-pack' ), 'settings' => add_query_arg( array( 'request' => 'autocomplete', 'post_type' => 'apf_posts' ) + $_GET, admin_url( AdminPageFramework_WPUtility::getPageNow() ) ), 'settings2' => array( // equivalent to the second parameter of the tokenInput() method 'tokenLimit' => 5, 'preventDuplicates' => true, 'theme' => 'facebook', 'searchDelay' => 50, // 50 milliseconds. Default: 300 ), ), array( 'type' => 'autocomplete', 'field_id' => 'autocomplete_mixed_field_types', 'title' => __( 'Mixed Post Types', 'admin-page-framework-field-type-pack' ), 'settings' => add_query_arg( array( 'request' => 'autocomplete', 'post_types' => 'post, page, apf_posts', // Note that the argument key is not 'post_type' 'post_status' => 'publish, private', ) + $_GET, admin_url( AdminPageFramework_WPUtility::getPageNow() ) ), 'settings2' => array( 'theme' => 'admin_page_framework', ), ), array( 'type' => 'autocomplete', 'field_id' => 'autocomplete_repeatable_field', 'title' => __( 'Repeatable', 'admin-page-framework-field-type-pack' ), 'repeatable' => true, ), array( 'type' => 'autocomplete', 'field_id' => 'autocomplete_users', 'title' => __( 'Search Users', 'admin-page-framework-field-type-pack' ), 'settings' => add_query_arg( array( 'request' => 'autocomplete', 'type' => 'user', // Note that the argument key is not 'post_type' ) + $_GET, admin_url( AdminPageFramework_WPUtility::getPageNow() ) ), 'settings2' => array( 'theme' => 'admin_page_framework', 'hintText' => __( 'Type a user name.', 'auto-post' ), 'preventDuplicates' => true, ), )
Since: 1.0.0
See: http://loopj.com/jquery-tokeninput/
Remark: Utilize the tokeninput jQuery plugin.
Located at custom-field-types/autocomplete-custom-field-type/AutocompleteCustomFieldType.php
Methods summary
protected
|
|
public
|
|
public
|
#
_replyToModifyMySQLWhereClauseToSearchUsers( mixed $oWPQuery )
Modifies the WordPress database query. |
public
|
#
_replyToModifyMySQLWhereClauseToSearchPosts( mixed $sWhere, mixed $oWPQuery )
Modifies the WordPress database query. |
protected
|
#
setUp( )
Loads the field type necessary components. This method is triggered when a field definition array that calls this field type is parsed. |
protected
|
#
getEnqueuingScripts( )
Returns an array holding the urls of enqueuing scripts. The returning array should be composed with all numeric keys. Each element can be either a string( the url or the path of the source file) or an array of custom argument. Custom Argument Array
|
protected
|
#
getEnqueuingStyles( )
Returns an array holding the urls of enqueuing styles. Custom Argument Array
|
protected
|
|
protected
|
|
protected
|
|
protected
|
Magic methods summary
Properties summary
public
array
|
$aFieldTypeSlugs |
#
Defines the field type slugs used for this field type. The slug is used for the type key in a field definition array. $this->addSettingFields( array( 'section_id' => '...', 'type' => 'autocomplete', // <--- THIS PART 'field_id' => '...', 'title' => '...', ) ); |
protected
array
|
$aDefaultKeys |
#
Defines the default key-values of this field type. The keys are used for the field definition array. $this->addSettingFields( array( 'section_id' => '...', 'type' => '...', 'field_id' => '...', 'my_custom_key' => '...', // <-- THIS PART ) ); Remark
$_aDefaultKeys holds shared default key-values defined in the base class.
|