|
| 1 | +<?php |
| 2 | +require '../vendor/autoload.php'; |
| 3 | +require 'utils.php'; |
| 4 | +use NitroXy\PHPForms\Form; |
| 5 | +?> |
| 6 | +<!DOCTYPE html> |
| 7 | +<html> |
| 8 | + <head> |
| 9 | + <title>PHP-Forms - Options</title> |
| 10 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> |
| 11 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"> |
| 12 | + <style> |
| 13 | + .form.table { margin-bottom: 0; /* override bootstrap */ } |
| 14 | + .form.table textarea { width: 100%; } |
| 15 | + .example { border: 1px dashed #ccc; padding: 15px; border-radius: 4px; margin-bottom: 10px; } |
| 16 | + </style> |
| 17 | + </head> |
| 18 | + <body> |
| 19 | + <div class="container"> |
| 20 | + <h1>PHP Forms <small>Options</small></h1> |
| 21 | + <?php include('menu.php') ?> |
| 22 | + |
| 23 | + <h2>Form options</h2> |
| 24 | + <dl> |
| 25 | + <dt>method</dt> |
| 26 | + <dd>Form method (default: post)</dd> |
| 27 | + <dt>method_field_name</dt> |
| 28 | + <dd>Name of the special method field when using methods other than <tt>GET</tt> and <tt>POST</tt></dd> |
| 29 | + <dt>action</dt> |
| 30 | + <dd>Form action (default: "")</dd> |
| 31 | + <dt>enctype</dt> |
| 32 | + <dd>Form enctype</dd> |
| 33 | + <dt>layout</dt> |
| 34 | + <dd>Form layout ("plain", "table", "bootstrap" or an instance of <code>FormLayout</code>)</dd> |
| 35 | + <dt>prefix</dt> |
| 36 | + <dd>Use custom prefix when generating names and ID</dd> |
| 37 | + <dt>Other</dt> |
| 38 | + <dd>Form also accepts <code>style</code>, <code>class</code> and <code>data</code> which is just passed directly to the form.</dd> |
| 39 | + </dl> |
| 40 | + |
| 41 | + <h3>Default options</h3> |
| 42 | + <p>Default options for forms can be set by extending <code>default_options</code>:</p> |
| 43 | + <?php display('overview/options.php'); ?> |
| 44 | + |
| 45 | + <h2>Field options</h2> |
| 46 | + <dl> |
| 47 | + <dt>hint</dt> |
| 48 | + <dd>Description of the field</dd> |
| 49 | + <dt>confirm</dt> |
| 50 | + <dd>Buttons: adds a javascript confirmation prompt before submit/click</dd> |
| 51 | + <dt>remove</dt> |
| 52 | + <dd>Upload: adds a removal checkbox (e.g. a user avatar which is set if file is uploaded but retained if nothing is sent and removed if checkbox is checked)</dd> |
| 53 | + <dt>Other</dt> |
| 54 | + <dd>All other attributes is passed directly to field, allowing custom attributes such as <code>placeholder</code>, <code>title</code>, etc.</dd> |
| 55 | + </dl> |
| 56 | + |
| 57 | + <h2>Serialization</h2> |
| 58 | + <p>Most attributes is serialized using these rules:</p> |
| 59 | + <ul> |
| 60 | + <li><code>['foo' => 'bar']</code> becomes <code>foo="bar"</code></li> |
| 61 | + <li><code>['foo' => ['a', 'b', 'c']]</code> becomes <code>foo="a b c"</code> (order preserved)</li> |
| 62 | + <li><code>['foo' => ['spam => 'ham']]</code> becomes <code>foo-spam="ham"</code> (deeper nesting is ok)</li> |
| 63 | + </ul> |
| 64 | + </div> |
| 65 | + <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> |
| 66 | + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> |
| 67 | + </body> |
| 68 | +</html> |
0 commit comments