PHP code example of code16 / formoj
1. Go to this page and download the library: Download code16/formoj 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/ */
code16 / formoj example snippets
return [
// config/sharp.php
[...],
"entities" => [
"formoj_form" => [
"label" => "Form",
"list" => \Code16\Formoj\Sharp\FormojFormSharpEntityList::class,
"show" => \Code16\Formoj\Sharp\FormojFormSharpShow::class,
"form" => \Code16\Formoj\Sharp\FormojFormSharpForm::class,
"validator" => \Code16\Formoj\Sharp\FormojFormSharpValidator::class,
],
"formoj_section" => [
"label" => "Section",
"list" => \Code16\Formoj\Sharp\FormojSectionSharpEntityList::class,
"form" => \Code16\Formoj\Sharp\FormojSectionSharpForm::class,
"show" => \Code16\Formoj\Sharp\FormojSectionSharpShow::class,
"validator" => \Code16\Formoj\Sharp\FormojSectionSharpValidator::class,
],
"formoj_field" => [
"label" => "Field",
"list" => \Code16\Formoj\Sharp\FormojFieldSharpEntityList::class,
"form" => \Code16\Formoj\Sharp\FormojFieldSharpForm::class,
"validator" => \Code16\Formoj\Sharp\FormojFieldSharpValidator::class,
],
"formoj_answer" => [
"label" => "Answer",
"list" => \Code16\Formoj\Sharp\FormojAnswerSharpEntityList::class,
"show" => \Code16\Formoj\Sharp\FormojAnswerSharpShow::class,
"policy" => \Code16\Formoj\Sharp\Policies\FormojAnswerSharpPolicy::class,
],
"formoj_reply" => [
"list" => \Code16\Formoj\Sharp\FormojReplySharpEntityList::class,
"policy" => \Code16\Formoj\Sharp\Policies\FormojReplySharpPolicy::class,
],
],
"menu" => [
[
"label" => "Formoj",
"entities" => [
[
"entity" => "formoj_form",
"label" => "Forms",
"icon" => "fa-list-alt"
]
]
]
],
[...]
];
$section = $form->createSection("My section");
$text = $section->newTextField("text")
->setRequired()
->setHelpText("help")
->setMaxLength(50)
->create();
$select = $section->newSelectField("select", ["option A", "option B"])
->setRequired()
->setHelpText("help")
->setMultiple()->setMaxOptions(2)
->create();
<formoj form-id="1"></formoj>
ExportAnswersToXls::dispatch($form, $fileName, $answers);
shell
php artisan migrate
shell
php artisan vendor:publish --provider="Code16\Formoj\FormojServiceProvider" --tag="config"
shell
php artisan vendor:publish --provider="Code16\Formoj\FormojServiceProvider" --tag="lang"