117 lines
4.8 KiB
PHP
Executable File
117 lines
4.8 KiB
PHP
Executable File
<?php
|
|
use phpformbuilder\Form;
|
|
use phpformbuilder\Validator\Validator;
|
|
|
|
/* =============================================
|
|
start session and include form class
|
|
============================================= */
|
|
|
|
session_start();
|
|
include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/phpformbuilder/Form.php';
|
|
|
|
|
|
/* =============================================
|
|
Select skin depending on poste value if any
|
|
============================================= */
|
|
|
|
$skin = 'yellow';
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && Form::testToken('custom-radio-checkbox-css-form') === true) {
|
|
if (preg_match('`^[a-z]+$`', $_POST['change-skin'])) {
|
|
$skin = $_POST['change-skin'];
|
|
}
|
|
}
|
|
|
|
/* ==================================================
|
|
The Form
|
|
================================================== */
|
|
|
|
$form = new Form('custom-radio-checkbox-css-form', 'horizontal', 'novalidate', 'bs3');
|
|
// set mode to 'development' to avoid caching the nice-check plugin skin CSS
|
|
$form->setMode('development');
|
|
$form->startFieldset('CSS radio buttons & Checkboxes - <small class="text-muted">Built using Custom CSS plugin</small>');
|
|
$form->addRadio('vertical-radio', 'One', 1);
|
|
$form->addRadio('vertical-radio', 'Two', 2, 'checked');
|
|
$form->printRadioGroup('vertical-radio', 'Vertical radio buttons', false);
|
|
$form->addCheckbox('vertical-checkbox', 'First', 1);
|
|
$form->addCheckbox('vertical-checkbox', 'Second', 2, 'checked');
|
|
$form->addCheckbox('vertical-checkbox', 'Third', 3);
|
|
$form->printCheckboxGroup('vertical-checkbox', 'Vertical checkboxes', false);
|
|
$form->addRadio('horizontal-radio', 'One', 1, 'checked');
|
|
$form->addRadio('horizontal-radio', 'Two', 2, 'checked');
|
|
$form->printRadioGroup('horizontal-radio', 'horizontal radio buttons', true);
|
|
$form->addCheckbox('horizontal-checkbox', 'First', 1);
|
|
$form->addCheckbox('horizontal-checkbox', 'Second', 2);
|
|
$form->addCheckbox('horizontal-checkbox', 'Third', 3, 'checked');
|
|
$form->printCheckboxGroup('horizontal-checkbox', 'Horizontal checkboxes', true);
|
|
$form->addRadio('change-skin', 'Grey', 'grey');
|
|
$form->addRadio('change-skin', 'Red', 'red');
|
|
$form->addRadio('change-skin', 'Green', 'green');
|
|
$form->addRadio('change-skin', 'Blue', 'blue');
|
|
$form->addRadio('change-skin', 'Yellow', 'yellow');
|
|
$form->addRadio('change-skin', 'Purple', 'purple');
|
|
$form->printRadioGroup('change-skin', 'Change Skin', false);
|
|
$options = array('buttonWrapper' => '<div class="form-group"></div>');
|
|
$form->setOptions($options);
|
|
$form->addBtn('submit', 'submit-btn', 1, 'Change Skin <span class="glyphicon glyphicon-tint append"></span>', 'class=btn btn-success ladda-button, data-style=zoom-in');
|
|
$form->endFieldset();
|
|
|
|
// Custom radio & checkbox css
|
|
$form->addPlugin('nice-check', 'form', 'default', ['%skin%' => $skin]);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Bootstrap Form with Custom CSS3 radio buttons and checkboxes - How to create PHP forms easily</title>
|
|
<meta name="description" content="Bootstrap Form Generator - how to create Custom CSS3 radio buttons and checkboxes">
|
|
<link rel="canonical" href="https://www.phpformbuilder.pro/templates/bootstrap-3-forms/custom-radio-checkbox-css-form.php" />
|
|
<!-- Link to Bootstrap css here -->
|
|
<?php
|
|
|
|
/* =============================================
|
|
CODE PREVIEW - REMOVE THIS IN YOUR FORMS
|
|
AND REPLACE WITH BOOTSTRAP CSS
|
|
FOR EXAMPLE <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
|
============================================= */
|
|
|
|
include_once '../assets/code-preview-head.php';
|
|
?>
|
|
<?php $form->printIncludes('css'); ?>
|
|
</head>
|
|
<body>
|
|
<h1 class="text-center">Php Form Builder - Bootstrap Form<br><small>with Custom CSS3 radio buttons and checkboxes</small></h1>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
|
|
<?php
|
|
$form->render();
|
|
echo '<p>Code: <code>$form->addPlugin(\'nice-check\', \'form\', \'default\', [\'%skin%\' => \'' . $skin . '\']);</code></p>';
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- jQuery -->
|
|
|
|
<script src="//code.jquery.com/jquery.min.js"></script>
|
|
|
|
<!-- Bootstrap JavaScript -->
|
|
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
|
<?php
|
|
$form->printIncludes('js');
|
|
$form->printJsCode();
|
|
?>
|
|
<?php
|
|
|
|
/* =============================================
|
|
CODE PREVIEW - REMOVE THIS IN YOUR FORMS
|
|
============================================= */
|
|
|
|
include_once '../assets/code-preview-body.php';
|
|
?>
|
|
</body>
|
|
</html>
|