Text
Purpose: multiline text, html markup
Field type in SQL table: longtext
Additional parameters:
rich_text
Purpose: adding a visual editor for html formatting of content, using the CKEditor
editor Possible values: true, false
Default: false
height
Purpose: height of the text area or visual editor (when the rich_text option is enabled), in pixels
Possible values: integer, positive, non-zero
Default: 100 (for a regular text area and 200 for a visual editor)
show_in_admin
Purpose: by default, text fields are not displayed in the administrative interface in the records table due to their large length. If you want to enable the display of this field in the list, you must set this parameter to an integer. This number will be the maximum length of the string, and the rest will be truncated.
Possible values: integer, positive, non-zero
Default: false
display_method
Purpose: allows you to override the method for generating HTML code in the administrative panel for this field, the method must be defined in the current model, the value of the database cell will be passed as an input argument
Possible values: strings like 'nameOfMethod'
Default: null
virtual
Purpose: allows you to create virtual fields in the model without a column in the database. Usually combined with the display_method option. Migrations do not offer to create a column for a virtual field. Also, such a field does not participate in the operation of creating or updating a record in the model. It only displays data in the right place in the admin panel
Possible values: true, false
Default: false
Examples:
['Comment', 'text', 'comment']
['Article Content', 'text', 'content', ['rich_text' => true]]
['Product Description', 'text', 'item_description', ['rich_text' => true,
'height' => 400,
'show_in_admin' => 70]]
['Order Contents', 'text', 'order_products', ['display_method' => 'displayOrder']]
['Special Field', 'text', 'special_field', ['display_method' => 'displaySpesialField',
'virtual' => true])
//Method to display field
class Orders extends Model
{
...
public function displayOrder($value)
{
$html = ...
//Processing $value
return $html;
}
}
Previous section
Password