Skip to content

Commit 9feffd3

Browse files
committed
docs: move options to separate page
1 parent b6cad8d commit 9feffd3

File tree

4 files changed

+71
-43
lines changed

4 files changed

+71
-43
lines changed

docs/index.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<li><a href="#methods">HTTP Methods (REST verbs)</a></li>
3131
<li><a href="#persistent">Persistent values</a></li>
3232
<li><a href="#controls">Supported controls</a></li>
33-
<li><a href="#options">Options</a></li>
3433
<li><a href="#nested">Nested data/"forms"</a></li>
3534
</ol>
3635

@@ -107,46 +106,6 @@
107106
<?php include('overview/controls.php'); ?>
108107
</div>
109108

110-
<h2 id="options">Options</h2>
111-
<h3>Form options</h3>
112-
<dl>
113-
<dt>method</dt>
114-
<dd>Form method (default: post)</dd>
115-
<dt>method_field_name</dt>
116-
<dd>Name of the special method field when using methods other than <tt>GET</tt> and <tt>POST</tt></dd>
117-
<dt>action</dt>
118-
<dd>Form action (default: "")</dd>
119-
<dt>enctype</dt>
120-
<dd>Form enctype</dd>
121-
<dt>layout</dt>
122-
<dd>Form layout ("plain", "table", "bootstrap" or an instance of <code>FormLayout</code>)</dd>
123-
<dt>prefix</dt>
124-
<dd>Use custom prefix when generating names and ID</dd>
125-
<dt>Other</dt>
126-
<dd>Form also accepts <code>style</code>, <code>class</code> and <code>data</code> which is just passed directly to the form.</dd>
127-
</dl>
128-
<p>Default options for forms can be set by extending <code>default_options</code>:</p>
129-
<?php display('overview/options.php'); ?>
130-
<h3>Fields</h3>
131-
<dl>
132-
<dt>hint</dt>
133-
<dd>Description of the field</dd>
134-
<dt>confirm</dt>
135-
<dd>Buttons: adds a javascript confirmation prompt before submit/click</dd>
136-
<dt>remove</dt>
137-
<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>
138-
<dt>Other</dt>
139-
<dd>All other attributes is passed directly to field, allowing custom attributes such as <code>placeholder</code>, <code>title</code>, etc.</dd>
140-
</dl>
141-
142-
<h3>Serialization</h3>
143-
<p>Most attributes is serialized using these rules:</p>
144-
<ul>
145-
<li><code>['foo' => 'bar']</code> becomes <tt>foo="bar"</tt></li>
146-
<li><code>['foo' => ['a', 'b', 'c']]</code> becomes <tt>foo="a b c"</tt> (order preserved)</li>
147-
<li><code>['foo' => ['spam => 'ham']]</code> becomes <tt>foo-spam="ham"</tt> (deeper nesting is ok)</li>
148-
</ul>
149-
150109
<h2 id="nested" >Nested data/"forms"</h2>
151110
<p>Forms can be nested by using <code>fields_for</code> to allow either sending to unrelated objects or multiple instances of the same class.</p>
152111
<?php display('overview/nested.php'); ?>

docs/menu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<li><a href="layout_bootstrap.php">Bootstrap</a></li>
1111
</ul>
1212
</li>
13+
<li><a href="options.php">Options</a></li>
1314
</ul>
1415
</div>
1516
</nav>

docs/options.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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>

docs/overview/options.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<?php
55
class MyForm extends Form {
66
static protected function default_options(){
7-
return array(
7+
return [
88
'layout' => 'bootstrap',
9-
);
9+
];
1010
}
1111
};
1212

0 commit comments

Comments
 (0)