-
Notifications
You must be signed in to change notification settings - Fork 0
Text
Text fields are probably the most common type of fields that you will use.
In Ultimate Fields text fields have various options, which let you fine-tune them to the highest degree.
Placeholder texts use the HTML5 placeholder attribute in order to show a grayed-out text before there is any user input.
In PHP they are managed by the set_placeholder_text( $text )
method:
Field::create( 'text', 'available_colors' )->set_placeholder_text( 'green, blue, orange' );
Prefixes and suffixes appear before and after the field respectively. Normally they indicate that the field is expecting a specific unit.
They are managed through the set_prefix
and set_suffix
methods of the field, which expect a single string parameter.
Field::create( 'text', 'price' )
->set_prefix( '€' )
->set_sufix( '.00' )
You can provide autocomplete suggestions for text fields. Ultimate FIelds uses the jQuery UI Autocomplete plugin in order to display those suggestions while users are typing.
In PHP this is done through the add_suggestions
mehod, which expects an array of strings:
Field::create( 'text', 'favorite_language' )
->add_autocomplete_suggestions( array( 'PHP', 'JavaScript', 'HTML', 'CSS' ) );
In order to avoid XSS attacs, the value of text fields is formatted through the esc_html
function.
In PHP, you can use the set_output_format
method of the text field to choose what to use:
-
false
will prevents any formatting from happening. -
"html"
will switch to using theesc_html
function.
Field::create( 'text', 'subtitle' )
->set_output_format( 'html' )
Quick start
- Creating fields and using their values
- Installation
- Administration interface
- Using the PHP API
- Container Settings
Locations
- Overview & Usage
- Post Type
- Options Page
- Taxonomy
- Comment
- User
- Widget
- Shortcode
- Menu Item
- Attachment
- Customizer
Fields
- Fields
- Text
- Textarea
- WYSIWYG
- Password
- Checkbox
- Select
- Multiselect
- Image Select
- File
- Image
- Audio
- Video
- Gallery
- WP Object
- WP Objects
- Link
- Date
- DateTime
- Time
- Color
- Font
- Icon
- Map
- Embed
- Number
- Sidebar
- Complex
- Repeater
- Layout
- Section
- Tab
- Message
Features
- Adding fields to the Customizer
- Conditional Logic
- Front-End Forms
- Administration columns
- Import and Export
- REST API
- JSON Synchronization
- Yoast SEO
Ultimate Post Types
Functions and API
Tutorials