すべてのヘルパーは自動的に適切なエスケープを適用します。これはつまり、{{= ... }}を使って出力することができます。もし、{{h ... }}などを使うと、二重にエスケープして出力してしまいます。
PHPのテンプレートコードで、ヘルパーを$thisのメソッドとして指定することもできます。
このようにフォームを開きます。
{{= form ([                         // (array) attributes
    'method' => 'post',
    'action' => '/hello',
]) }}
<form method="post" action="/hello" enctype="multipart/form-data">
フォームを閉じるには、</form>を使用します。
checkboxFieldは汎用の入力フィールドヘルパーとして使用できますが、チェック済みかどうかをマークするために、自分でchecked属性を設定する必要があります。
代わりに、擬似属性_optionsを指定すると、より高機能なものが利用できるようになります。
_optionsは、フィールドの一部として1つ以上のチェックボックスを指定し、チェックされたときの値と、それに対応するラベルを指定します。
_optionsが複数の要素を持つ場合、フィールド名には自動的に[]が付加され、配列となります。
value属性は_optionsと照合され、正しいチェックボックスがcheckedされるようになります。
default疑似属性が存在する場合、チェックボックスがチェックされていないとき、値のための隠された入力フィールドを生成します。
{{= checkboxField ([                // (array) attributes
    'name' => 'flags',
    'value' => 'bar',
    '_default' => '',
    '_options' => [
        'foo' => 'Foo Flag',
        'bar' => 'Bar Flag',
        'baz' => 'Baz Flag',
    ]
]) }}
<input type="hidden" name="flags" value="" />
<label><input type="checkbox" name="flags[]" value="foo" /> Foo Flag</label>
<label><input type="checkbox" name="flags[]" value="bar" checked /> Bar Flag</label>
<label><input type="checkbox" name="flags[]" value="baz" /> Baz Flag</label>
{{= colorField ([                   // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="color" name="foo" value="bar" />
{{= dateField ([                    // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="date" name="foo" value="bar" />
{{= datetimeField ([                // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="datetime" name="foo" value="bar" />
{{= datetimeLocalField ([           // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="datetime-local" name="foo" value="bar" />
{{= emailField ([                   // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="email" name="foo" value="bar" />
{{= fileField ([                    // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="file" name="foo" value="bar" />
{{= hiddenField ([                  // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="hidden" name="foo" value="bar" />
一般的な入力フィールド。必要なtypeを指定する。
{{= inputField ([                  // (array) attributes
    'type' => 'text',
    'name' => 'foo',
    'value' => 'bar',
    // ...
]) }}
<input type="text" name="foo" value="bar" />
{{= monthField ([                   // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="month" name="foo" value="bar" />
{{= numberField ([                  // (array) attributes
    'type' => 'number',
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="number" name="foo" value="bar" />
{{= passwordField ([                // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="password" name="foo" value="bar" />
radioFieldを汎用の入力フィールドヘルパーとして使用することができますが、チェック済みかどうかをマークするために、自分でchecked属性を設定する必要があります。
また、擬似属性 _optionsを指定することで、より高機能なものが利用できます。
_optionsは、フィールドの一部として1つまたは複数のラジオボタンを指定し、チェックしたときの値と、それに対応するラベルを指定します。
value属性が_optionsとマッチングされ、適切なチェックボックスがcheckedされるようになります。
{{= radioField ([                   // (array) attributes
    'name' => 'foo',
    'value' => 'baz',
    '_options' => [
        'bar' => 'Bar Label',
        'baz' => 'Baz Label,
        'dib' => 'Dib Label',
    ),
]) }}
<label><input type="radio" name="foo" value="bar" /> Bar Label</label>
<label><input type="radio" name="foo" value="baz" checked /> Baz Label</label>
<label><input type="radio" name="foo" value="dib" /> Dib Label</label>
{{= rangeField ([                   // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="range" name="foo" value="bar" />
{{= searchField ([                  // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="search" name="foo" value="bar" />
<option>タグの記述には、擬似属性_optionsを使用します。
属性placeholderは、オプションが選択されていない場合、プレースホルダー・ラベルとして尊重されます。擬似属性_defaultは、プレースホルダーの値を指定します。
属性'multiple' => trueを使用すると、複数選択が設定され、名前に[]がない場合は自動的に追加されます。
{{= select ([                       // (array) attributes
    'name' => 'foo',
    'value' => 'dib',
    'placeholder' => 'Please pick one',
    '_default' => '',
    '_options' => [
        'bar' => 'Bar Label',
        'baz' => 'Baz Label',
        'dib' => 'Dib Label',
        'zim' => 'Zim Label',
    ],
]) }}
<select name="foo">
    <option value="" disabled>Please pick one</option>
    <option value="bar">Bar Label</option>
    <option value="baz">Baz Label</option>
    <option value="dib" selected>Dib Label</option>
    <option value="zim">Zim Label</option>
</select>
このヘルパーはオプショングループもサポートしています。もし_options配列の値そのものが配列なら、その要素のキーが <optgroup>ラベルとして使われ、値の配列は、そのグループのオプションとなります。
{{= select ([
    'name' => 'foo',
    'value' => 'bar',
    '_options' => [
        'Group A' => [
            'bar' => 'Bar Label',
            'baz' => 'Baz Label',
        ],
        'Group B' => [
            'dib' => 'Dib Label',
            'zim' => 'Zim Label',
        ],
    ],
]) }}
<select name="foo">
    <optgroup label="Group A">
        <option value="bar">Bar Label</option>
        <option value="baz">Baz Label</option>
    </optgroup>
    <optgroup label="Group B">
        <option value="dib" selected>Dib Label</option>
        <option value="zim">Zim Label</option>
    </optgroup>
</select>
{{= telField([                      // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="tel" name="foo" value="bar" />
{{= textField ([                    // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="text" name="foo" value="bar" />
{{= textarea ([                     // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<textarea name="foo">bar</textarea>
{{= timeField ([                    // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="time" name="foo" value="bar" />
{{= urlField ([                      // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="url" name="foo" value="bar" />
{{= weekField ([                    // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="week" name="foo" value="bar" />
各種ボタンタグのヘルパーです。
{{= button ([                       // (array) atttributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="button" name="foo" value="bar" />
{{= imageButton ([                  // (array) atttributes
    'name' => 'foo',
    'src' => '/images/map.png',
]) }}
<input type="image" name="foo" src="/images/map.png" />
{{= submitButton ([                 // (array) atttributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="submit" name="foo" value="bar" />
{{= resetButton ([                  // (array) attributes
    'name' => 'foo',
    'value' => 'bar',
]) }}
<input type="reset" name="foo" value="bar" />
<label>タグ用のヘルパーです。
{{= label (
    'Label For Field',              // (string) label text
    [                               // (array) optional attributes
        'for' => 'field'
    ]
) }}
<label for="field">Label For Field</label>