TText Element

A form example demonstrating how to use the TTextElement field in VueForm Laravel to capture single-line text input in multiple languages within a Laravel form. Documentation


🧱 Import Class

use VueFormLaravel\Abstracts\VueFormBuilder;
use VueFormLaravel\Elements\Fields\TTextElement;
use VueFormLaravel\Elements\Vueform;

🧩 Example

class TTextElementForm extends VueFormBuilder
{
    protected function buildForm()
    {
        return Vueform::build()
            ->schema([
                TTextElement::name('search')
            ]);
    }

    public static function formData($request)
    {
        $request->validate([
            'search' => 'required'
        ]);

        return response()->json([
            'status' => 'success'
        ]);
    }
}

⚙️ Allowed Attributes

Name Data Type Default Example
addClass array|object|string|function null TTextElement::name("name")->addClass()
addClasses object|function {} TTextElement::name("name")->addClasses()
addons object {} TTextElement::name("name")->addons()
after object|string|number null TTextElement::name("name")->after()
attrs object {} TTextElement::name("name")->attrs()
autocomplete string|number null TTextElement::name("name")->autocomplete()
before object|string|number null TTextElement::name("name")->before()
between object|string|number null TTextElement::name("name")->between()
columns object|string|number null TTextElement::name("name")->columns()
conditions array [] TTextElement::name("name")->conditions()
debounce number null TTextElement::name("name")->debounce()
default object|string|number undefined TTextElement::name("name")->default()
description string|object null TTextElement::name("name")->description()
disabled boolean|function|array|object false TTextElement::name("name")->disabled()
displayErrors boolean true TTextElement::name("name")->displayErrors()
fieldName string|object name label
floating string|boolean|object null TTextElement::name("name")->floating()
formatData function null TTextElement::name("name")->formatData()
formatLoad function null TTextElement::name("name")->formatLoad()
id string null TTextElement::name("name")->id()
info string|object null TTextElement::name("name")->info()
infoPosition string right TTextElement::name("name")->infoPosition()
inline boolean false TTextElement::name("name")->inline()
inputType string text TTextElement::name("name")->inputType()
label string|object|function null TTextElement::name("name")->label()
loading boolean false TTextElement::name("name")->loading()
messages object {} TTextElement::name("name")->messages()
name string|number undefined TTextElement::name("name")->name()
overrideClass array|object|string|function null TTextElement::name("name")->overrideClass()
overrideClasses object|function {} TTextElement::name("name")->overrideClasses()
placeholder string|object null TTextElement::name("name")->placeholder()
presets array [] TTextElement::name("name")->presets()
readonly boolean|function|array|object false TTextElement::name("name")->readonly()
removeClass array|object|function null TTextElement::name("name")->removeClass()
removeClasses object|function {} TTextElement::name("name")->removeClasses()
replaceClass object|function null TTextElement::name("name")->replaceClass()
replaceClasses object|function {} TTextElement::name("name")->replaceClasses()
rules array|string|object null TTextElement::name("name")->rules()
size string undefined TTextElement::name("name")->size()
slots object {} TTextElement::name("name")->slots()
submit boolean true TTextElement::name("name")->submit()
templates object {} TTextElement::name("name")->templates()
view string undefined TTextElement::name("name")->view()
views object {} TTextElement::name("name")->views()

⚡ Events

You can define custom ttext element events Documentation directly in PHP using the ->events() method.

Each event value refers to a JavaScript function name.

These functions must be defined inside:

public/vueform-laravel/vueform-custom.js

This allows you to extend or override default behaviors for your generated VueForm components

Name Parameters Description
reset - {component} el$ - the element's component Triggered when the input is resetted.
clear - {component} el$ - the element's component Triggered when the input is cleared.
change - {string} newValue - the new value
- {string} oldValue - the old value
- {component} el$ - the element's component
Triggered when the element's value is changed.
blur - {component} el$ - the element's component Triggered when the input is blurred.
focus - {component} el$ - the element's component Triggered when the input is focused.
keydown - {Event} Event - the Event object
- {component} el$ - the element's component
Triggered on keydown.
keyup - {Event} Event - the Event object
- {component} el$ - the element's component
Triggered on keyup.
keypress - {Event} Event - the Event object
- {component} el$ - the element's component
Triggered on keypress.
beforeCreate - {component} el$ - the element's component Triggered in beforeCreate hook.
created - {component} el$ - the element's component Triggered in created hook.
beforeMount - {component} el$ - the element's component Triggered in beforeMount hook.
mounted - {component} el$ - the element's component Triggered in mounted hook.
beforeUpdate - {component} el$ - the element's component Triggered in beforeUpdate hook.
updated - {component} el$ - the element's component Triggered in updated hook.
beforeUnmount - {component} el$ - the element's component Triggered in beforeUnmount (or beforeDestroy in Vue 2) hook.
unmounted - {component} el$ - the element's component Triggered in unmounted (or destroyed in Vue 2) hook.

🔔 Example Usage of event (PHP)

TTextElement::name('example')
    ->events([
        'reset' => 'handleReset',
        'clear' => 'handleClear',
        'change' => 'handleChange',
        'blur' => 'handleBlur',
        'focus' => 'handleFocus',
        'keydown' => 'handleKeydown',
        'keyup' => 'handleKeyup',
        'keypress' => 'handleKeypress',
        'beforeCreate' => 'handleBeforeCreate',
        'created' => 'handleCreated',
        'beforeMount' => 'handleBeforeMount',
        'mounted' => 'handleMounted',
        'beforeUpdate' => 'handleBeforeUpdate',
        'updated' => 'handleUpdated',
        'beforeUnmount' => 'handleBeforeUnmount',
        'unmounted' => 'handleUnmounted',
    ])

🔔 Example Usage of event(JavaScript)

function handleReset(el$) {
    // Your code here
}
function handleClear(el$) {
    // Your code here
}
function handleChange(newValue, oldValue, el$) {
    // Your code here
}
function handleBlur(el$) {
    // Your code here
}
function handleFocus(el$) {
    // Your code here
}
function handleKeydown(Event, el$) {
    // Your code here
}
function handleKeyup(Event, el$) {
    // Your code here
}
function handleKeypress(Event, el$) {
    // Your code here
}
function handleBeforeCreate(el$) {
    // Your code here
}
function handleCreated(el$) {
    // Your code here
}
function handleBeforeMount(el$) {
    // Your code here
}
function handleMounted(el$) {
    // Your code here
}
function handleBeforeUpdate(el$) {
    // Your code here
}
function handleUpdated(el$) {
    // Your code here
}
function handleBeforeUnmount(el$) {
    // Your code here
}
function handleUnmounted(el$) {
    // Your code here
}

⚡ Slots

The following slots Documentation are available for this element:

Name Scope Description
label - {component} el$ - the element's component Renders a label for the element in ElementLabel component.
info - {component} el$ - the element's component Renders an info icon in ElementInfo component next the the element label. When the icon is hovered it shows the content of this slot. The element needs to have a label to render this.
required -
description - {component} el$ - the element's component Renders description for the element in ElementDescription component.
before - {component} el$ - the element's component Renders an ElementText component before the input field.
between - {component} el$ - the element's component Renders an ElementText component after the input field and before description.
after - {component} el$ - the element's component Renders an ElementText component after the description and error.
addon-before - {component} el$ - the element's component Prepends an addon to the input field.
addon-after - {component} el$ - the element's component Appends an addon to the input field.