1. Go to this page and download the library: Download qteab/qterest library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qteab / qterest example snippets
$args = [
'wrapper_class' => "qterest-form-container", // (string) Overrides the default wrapper class
'form_class' => "qterest-form", // (string) Overrides the default form class
'form_row_class' => "qterest-form-row", // (string) Overrides the default form row class
'form_misc_class' => "qterest-form-misc", // (string) Overrides the default form misc class
'form_title' => "Contact form", // (string) Adds a h3-tag with the given content
'error_messages_class' => "qterest-error-messages", // (string) Overrides the default error message class
'success_message_class' => "qterest-success-messages", // (string) Overrides the default success message class
'form_fields_class' => "qterest-form-fields", // (string) Overrides the default form fields class
'submit_label' => __("Submit", 'qterest'), // (string) Overrides the default submit label
'submit_class' => 'button submit', // (string) Overrides the default submit class
'fields' => $fields, // (array) Check the next section
]
$fields = [
[
'type' => 'text', // REQUIRED (string) Possible values are text, email, file, tel, hidden and textarea
'name' => 'my_text_field', // REQUIRED (string) HTML Attribute name
'placeholder' => 'Text', // (string) HTML Attribute placeholder
'value' => 'some_value', // (string) HTML Attribute value
'label' => 'Text', // (string) Label text
'class' => 'form-control', // (string) Overrides default class
' class
'toggles' => true, // (bool) Can this field toggle other fields? ONLY checkbox
],
[
'type' => 'select', // REQUIRED (string) Possible values are select
'name' => 'my_text_field', // REQUIRED (string) HTML Attribute name
'placeholder' => 'Text', // (string) HTML Attribute placeholder
'value' => 'some_value', // (string) HTML Attribute value
'label' => 'Text', // (string) Label text
'class' => 'form-control', // (string) Overrides default class
'toggles_on' => 'my_checkbox_field', // (string) The id of the field that you want to toogle this field
'options' => [
[
'name' => 'My first option', // REQUIRED (string) The name of this option
'value' => 'my_first_option', // REQUIRED (string) The value of this option
],
[
'name' => 'My second option', // REQUIRED (string) The name of this option
'value' => 'my_second_option', // REQUIRED (string) The value of this option
]
]
],
]
$fields = [
[
'type' => 'title',
'text' => 'Hejsan',
'size' => '3' // This will be a h3 element
],
[
'type' => 'paragraph',
'text' => 'Lorem ipsum dolor sit'
],
[
'type' => 'link',
'href' => 'https://google.com',
'text' => 'Google.se'
]
]
qterest_render_form([
'form_title' => 'Simple contact form',
'submit_label' => __('Send', 'text_domain')
'fields' => [
[
'type' => 'text',
'name' => 'name',
'label' => 'Name',
'placeholder' => 'Sven Svensson',
],
[
'type' => 'email',
'name' => 'email', // This field is 'name' => 'gdpr',
'label' => 'I agree to the following <a href="google.se">terms</a>',
'
function theme_custom_qterest_messages($messages, $params) {
$messages['success'] = __("Thank you! We will contact you as soon as possible!", 'text_domain');
return $messages;
}
add_filter('qterest_contact_messages', 'theme_custom_qterest_messages', 10, 2);
function theme_remove_attachment_after_request($remove, $params, $post_id) {
// You may access $params or $post_id if you wish to remove attachments conditionally
$remove = true;
return $remove;
}
add_filter('qterest_contact_remove_attachments_after_request', 'theme_remove_attachment_after_request', 10, 3);
function theme_format_keys_bulk($key) {
return "Does this person have a dog?";
}
add_filter('qterest_format_key_has_dog', 'theme_format_key_has_dog');
function theme_format_bulk_keys($key) {
return [
'has_dog' => "Does this person have a dog?",
'email' => __("Email address", 'text_domain'), // TIP: You can use localization here if the site is multi language
]
}
add_filter('qterest_format_bulk_keys', 'theme_format_bulk_keys');