PHP code example of dakinquelia / formbuilder
1. Go to this page and download the library: Download dakinquelia/formbuilder 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/ */
dakinquelia / formbuilder example snippets
$attr_form = [
'method' => 'POST',
'class' => 'form',
'legend' => 'Informations',
'rowclass' => 'row',
];
$attr_user = [
'class' => "form-control",
'label' => "Nom d'utilisateur",
];
$attr_test = [
'class' => "form-control",
'label' => "Champ test",
'placeholder' => 'Mon placeholder'
];
$attr_radio = [
'label' => "Bouton Radio",
'class' => "form-radio"
];
$attr_select = [
'class' => "form-control",
'label' => "Champ test",
'options' => [
[
'label' => 'Test 1',
'value' => 'Valeur 1'
],
[
'label' => 'Test 2',
'value' => 'Valeur 2'
],
[
'label' => 'Test 3',
'value' => 'Valeur 3'
],
]
];
$attr_textarea = [
'class' => "form-control",
'label' => "Champ test",
'content' => "Mon contenu"
];
$button_submit = [
'label' => 'Envoyer',
'class' => 'button'
];
$button_cancel = [
'label' => 'Annuler',
'class' => 'button'
];
$rules = [];
$form = new Form('Titre de mon formulaire', $attr_form);
$form->AddField('username', 'text', $attr_user, $rules);
$form->AddField('test', 'text', $attr_test, $rules);
$form->AddField('radio', 'radio', $attr_radio, $rules);
$form->AddField('selection', 'select', $attr_select, $rules);
$form->AddField('message', 'textarea', $attr_textarea, $rules);
$form->AddButton('submit', 'submit', $button_submit);
$form->AddButton('canel', 'button', $button_cancel);
echo $form->Render();