CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 36
Snippet Form
Snippet Form is a feature that can convert the code snippets into forms
For example, in the case where a customer needs to reset his password, after a period of time, another customer needs me to manually reset his password.
Then I will open Tinkerun to modify some parameters in the code editor for resetting the password.
So I was thinking if I could have a Form to reset the password, it would be great.
Use a specific variable name prefix to define variables, Tinkerun will recognize these variables and convert them into forms,
By default, the variable name prefix is field_
.
For example, if you write the following code:
$field_word = 'Magic';
Then click the button Snippet Form
in the upper right corner 🌟, Tinkerun will convert the code into a form.

Now you can modify the value of this variable in the form.
Isn’t it simple?
You can also write more complicated, such as adding a label and description to the previous line of code:
$field_word = [
'value' => 'Magic',
'label' => 'A magic word',
'description' => 'this is a magic description',
]

Of course, it can be more complicated, let me show you.
Use the following code you can create a select
field, something like <select>
tag
$field_language = [
'value' => 'php',
'label' => 'Language',
'description' => 'Select a language you like, follow your heart.',
'type' => 'select',
'options' => [
[
'label' => 'Go',
'value' => 'go',
],
[
'label' => 'Rust',
'value' => 'rust',
],
[
'label' => 'PHP',
'value' => 'php',
],
[
'label' => 'Javacript',
'value' => 'js',
],
]
];
$field_language['value']

Use the following code you can create a checkbox
field, something like <input type="checkbox">
tag
$field_is_admin = [
'value' => false,
'label' => 'Is Admin',
'description' => 'is that user an admin',
'type' => 'checkbox',
];
$field_is_admin['value']

Use the following code you can create a switch
field
$field_is_admin = [
'value' => false,
'label' => 'Is Admin',
'description' => 'is that user an admin',
'type' => 'switch',
];
$field_is_admin['value']

Use the following code you can create a textarea
field, something like <textarea>
tag
$field_introduce = [
'value' => 'a long text',
'label' => 'Introduce',
'description' => 'a description for introduce',
'type' => 'textarea',
];
$field_introduce['value']

text
field is created by default, something like <input>
tag, it means the following three usage methods are the same
$field_word = 'Magic';
$field_word = [
'value' => 'Magic',
];
$field_word = [
'value' => 'Magic',
'type' => 'text',
];
and if you set the type
as number
, Tinkerun will create a field like <input type="number">
tag,
email
for <input type="email">
tag
Properties supported by the Snippet Form
Property | Description | Type | Default | Required |
---|---|---|---|---|
value | The value you want to modify through the form | string | int | float | bool | required | |
label | field label | string | ||
description | field description | string | ||
type | field type |
text | select | checkbox | switch | textarea | number | email
|
text | |
options | if the type is select , for more detail see section select
|
array | required if type is select
|
The default prefix for Snippet Form is field_
, you can custom it by open the Preferences
window

Enjoy!