Text
The Text field displays a single-line value and renders a regular <input type="text" /> element on forms.
# app/avo/resources/post.rb
class Avo::Resources::Post < Avo::BaseResource
def fields
field :title, as: :text
end
endBy default, values are displayed as escaped text, without links or HTML rendering.
Link to an email address or phone number
Set protocol to turn the value into a link on the Index and Show views. For example, :mailto opens an email client and :tel creates a phone link.
# app/avo/resources/user.rb
field :email,
as: :text,
protocol: :mailtoLink to the record
Set link_to_record to true to make the value link to the record on the Index view.
# app/avo/resources/post.rb
field :title, as: :text, link_to_record: trueRender HTML in a value
Set as_html to true to render the value as HTML on the Index and Show views. This is useful for custom markup, such as a link to another record or website.
# app/avo/resources/post.rb
field :title, as: :text, as_html: true do
'<a href="https://avohq.io">Avo</a>'
endWARNING
as_html renders the value without escaping or sanitizing it. Only render trusted HTML, or sanitize untrusted content before returning it.
For combined options, see the rendering precedence. These options do not change the text input on forms.
Customize the label and input
Use common field options to set a label, placeholder, required indicator, read-only input, or value formatting.
# app/avo/resources/post.rb
field :title,
as: :text,
name: "Post title",
required: true,
readonly: true,
placeholder: "My shiny new post",
format_display_using: -> { value.to_s.truncate(30) }