PHP code example of calderawp / forms
1. Go to this page and download the library: Download calderawp/forms 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/ */
calderawp / forms example snippets
$array = [
'id' => 'cf1',
'fields' => [
'name' => [
'id' => 'name',
'type' => 'input',
'label' => 'Your Name',
'umberOfItems',
'type' => 'input',
'label' => 'Total',
'description' => 'How many items?',
'fieldConfig' => [
'html5type' => 'number',
'attributes' => [
'min' => 0,
'step' => 1
]
]
],
'agreeToTerms' => [
'id' => 'agreeToTerms',
'type' => 'select',
'label' => 'Agree to terms',
'description' => 'Compliance is mandatory',
'fieldConfig' => [
'multiple' => false,
'options' => [
[
'value' => true,
'label' => 'Yes'
],
[
'value' => false,
'label' => 'No'
]
]
]
]
],
'processors' => [
[
'label' => 'Main Message',
'type' => 'testType',
'config' =>
[
'fromName' => 'fld1',
'fromEmail' => '[email protected] ',
]
]
]
];
$model = FormModel::fromArray($array);
$field = \calderawp\caldera\Forms\FieldModel::fromArray([
'id' => 'fld1',
'type' => 'input',
'slug' => 'name',
'label' => 'Your Name'
]);
$field = \calderawp\caldera\Forms\FieldModel::fromArray([
'id' => '',
'type' => 'input',
'html5type' => 'email',
'slug' => '',
'label' => '',
'description' => ''
]);
$field = \calderawp\caldera\Forms\FieldModel::fromArray([
'id' => '',
'type' => 'input',
'html5type' => 'number',
'slug' => '',
'label' => '',
'description' => '',
'attributes' => [
'min' => 5,
'max' => 12
]
]);