# Low Variables v2 Fieldtype Bridge Instead of making a variable type, you can also choose to create or modify a custom fieldtype. In order to add Low Variables support to your fieldtype, just create it like you normally would, using Pixel & Tonic’s FieldFrame v1.4.3+ for EE1, or EE2’s Fieldtype API. Then, all you need to do is add a couple of methods to your fieldtype class. It’s a lot like adding Matrix support. ## display_var_field _(required)_ Displays the input field on the module home page. You can access the current variable id with `$this->var_id`. ### Arguments - `$var_name` _(string, EE1 only)_ — The name used for the input field. - `$var_data` _(string)_ — The current variable data. - `$var_settings` _(array, EE1 only)_ — The current variable’s settings. ### Return A string containing the HTML to be used in the module’s home page. ## display_var_settings If the fieldtype has settings, use this method to display them. You can access the current variable id with `$this->var_id`. ### Arguments - `$var_settings` _(array)_ — The current variable’s settings. ### Return An array containing two elements: the name/label in the first element, the form element(s) in the second. ## save_var_settings Use this method to catch the settings values before saving them to the database. You can access the current variable id with `$this->var_id`. ### Arguments - `$var_settings` _(array)_ — The posted variable’s settings. ### Return An associative array containing the settings to be saved. ## post_save_var_settings (v2.2.0+) Use this method for additional processing when a (new) variable has been saved to the database. You can access the current variable id with `$this->var_id`. ### Arguments - `$var_settings` _(array)_ — The posted variable’s settings. ### Return `NULL` ## save_var_field Use this method to catch the variable value before saving it to the database. You can access the current variable id with `$this->var_id`. ### Arguments - `$var_data` _(string)_ — The posted variable data. - `$var_settings` _(array, EE1 only)_ — The current variable’s settings. ### Return A string containing the modified variable data to be saved. ## post_save_var Use this method to do something after the variable value has been saved to the database. You can access the current variable id with `$this->var_id` and the settings with `$this->settings`. ### Arguments - `$var_data` _(string)_ — The current variable data. ## display_var_tag Use this method for displaying the variable value in your templates, using the `{exp:low_variables:parse}`, `{exp:low_variables:single}` and `{exp:low_variables:pair}` tags. You can access the current variable id with `$this->var_id` and the variable settings with `$this->settings` (v2.2.1+). For Low Variables version 2.2.0 and _lower_, the settings will be available in the `$tagparams` argument. ### Arguments, EE1 - `$tagparams` _(array)_ — The tag parameters. - `$tagdata` _(string)_ — The current tag data. - `$var_data` _(string)_ — The current variable’s value. - `$var_settings` _(array)_ — The current variable’s settings. ### Arguments, EE2 - `$var_data` _(string)_ — The current variable’s value. - `$tagparams` _(array)_ — The tag parameters. - `$tagdata` _(string)_ — The current tag data. ### Return A string containing the modified tagdata. ## delete_var (v2.2.0+) Use this method for additional processing before a variable is deleted. ### Arguments - `$var_id` _(int)_ — The ID of the variable about to be deleted. ### Return `NULL`