baserCMS クラスリファレンス

BcFormHelper extends FormHelper
in package
Uses BcEventDispatcherTrait, BcContainerTrait

FormHelper 拡張クラス

Table of Contents

Properties

$BcCkeditor  : BcCkeditorHelper
$BcHtml  : BcHtmlHelper
$BcUpload  : BcUploadHelper
$helpers  : array<string|int, mixed>
Other helpers used by FormHelper
$_View  : View
View
$formId  : string
フォームID

Methods

ckeditor()  : string
CKEditorを出力する
control()  : string
フォームコントロールを取得
create()  : string
Returns an HTML form element.
datePicker()  : string
カレンダーピッカー
dateTimePicker()  : string
カレンダピッカーとタイムピッカー
dispatchAfterForm()  : string
フォームの最後のフィールドの後に発動する前提としてイベントを発動する
dispatchLayerEvent()  : bool|Event
イベントを発火
editor()  : string
エディタを表示する
end()  : string
Closes an HTML form, cleans up values set by FormHelper::create(), and writes hidden input fields where appropriate.
file()  : string
ファイルインプットボックス出力
getControlSource()  : array<string|int, mixed>|false
コントロールソースを取得する Model側でメソッドを用意しておく必要がある
getId()  : string
フォームのIDを取得する
getService()  : array<string|int, mixed>|mixed|object
Get Service
getTable()  : Table|false
フィールドに紐づくテーブルを取得する
hasService()  : bool
Has Service
hidden()  : string
Creates a hidden input field.
prefTag()  : string
都道府県用のSELECTタグを表示する
setId()  : string
フォームのIDを設定する
submit()  : string
Creates a submit button element. This method will generate `<input />` elements that can be used to submit, and reset forms by using $options. image submits can be created by supplying an image path for $caption.
createId()  : string
フォームのIDを作成する BcForm::create より呼出される事が前提

Properties

$helpers

Other helpers used by FormHelper

public array<string|int, mixed> $helpers = ['Url', 'Js', 'Html', 'BaserCore.BcHtml', 'BaserCore.BcTime', 'BaserCore.BcText', 'BaserCore.BcUpload', 'BaserCore.BcCkeditor']

Methods

ckeditor()

CKEditorを出力する

public ckeditor(string $fieldName[, array<string|int, mixed> $options = [] ]) : string
Parameters
$fieldName : string
$options : array<string|int, mixed> = []
Tags
checked
noTodo
Return values
string

control()

フォームコントロールを取得

public control(string $fieldName[, array<string|int, mixed> $options = [] ]) : string

CakePHPの標準仕様をカスタマイズ

  • labelタグを自動で付けない
  • legendタグを自動で付けない
  • errorタグを自動で付けない
Parameters
$fieldName : string
$options : array<string|int, mixed> = []
Tags
checked
noTodo
unitTest
Return values
string

create()

Returns an HTML form element.

public create([mixed $context = null ][, array<string|int, mixed> $options = [] ]) : string

Options:

  • type Form method defaults to autodetecting based on the form context. If the form context's isCreate() method returns false, a PUT request will be done.
  • method Set the form's method attribute explicitly.
  • url The URL the form submits to. Can be a string or a URL array.
  • encoding Set the accept-charset encoding for the form. Defaults to Configure::read('App.encoding')
  • enctype Set the form encoding explicitly. By default type => file will set enctype to multipart/form-data.
  • templates The templates you want to use for this form. Any templates will be merged on top of the already loaded templates. This option can either be a filename in /config that contains the templates you want to load, or an array of templates to use.
  • context Additional options for the context class. For example the EntityContext accepts a 'table' option that allows you to set the specific Table class the form should be based on.
  • idPrefix Prefix for generated ID attributes.
  • valueSources The sources that values should be read from. See FormHelper::setValueSources()
  • templateVars Provide template variables for the formStart template.
Parameters
$context : mixed = null

The context for which the form is being defined. Can be a ContextInterface instance, ORM entity, ORM resultset, or an array of meta data. You can use null to make a context-less form.

$options : array<string|int, mixed> = []

An array of html attributes and options.

Tags
link
https://book.cakephp.org/4/en/views/helpers/form.html#Cake\View\Helper\FormHelper::
checked
noTodo
unitTest
Return values
string

An formatted opening FORM tag.

datePicker()

カレンダーピッカー

public datePicker(mixed $fieldName[, mixed $options = [] ]) : string

jquery-ui-1系 必須

Parameters
$fieldName : mixed
$options : mixed = []
Tags
checked
noTodo
unitTest
Return values
string

html

dateTimePicker()

カレンダピッカーとタイムピッカー

public dateTimePicker(string $fieldName[, array<string|int, mixed> $options = [] ]) : string

jquery.timepicker.js 必須

Parameters
$fieldName : string
$options : array<string|int, mixed> = []
Tags
checked
noTodo
unitTest
Return values
string

dispatchAfterForm()

フォームの最後のフィールドの後に発動する前提としてイベントを発動する

public dispatchAfterForm([string $type = '' ]) : string

発動側

フォームのの直前に記述して利用する

コールバック処理

プラグインのコールバック処理で CakeEvent::data['fields'] に 配列で行データを追加する事でフォームの最後に行を追加する事ができる。

イベント名

コントローラー名.Form.afterForm Or コントローラー名.Form.afterOptionForm

行データのキー(配列)

  • title:見出欄
  • input:入力欄

行データの追加例

$View = $event->subject(); // $event は、CakeEvent $input = $View->BcForm->input('Page.add_field', ['type' => 'input']); $event->setData('fields', [ [ 'title' => '追加フィールド', 'input' => $input ] ]);

Parameters
$type : string = ''

フォームのタイプ タイプごとにイベントの登録ができる

Tags
checked
noTodo
Return values
string

行データ

dispatchLayerEvent()

イベントを発火

public dispatchLayerEvent(string $name[, array<string|int, mixed> $data = [] ][, mixed $options = [] ]) : bool|Event
Parameters
$name : string
$data : array<string|int, mixed> = []
$options : mixed = []
Tags
checked
unitTest
noTodo
Return values
bool|Event

editor()

エディタを表示する

public editor(string $fieldName[, array<string|int, mixed> $options = [] ]) : string
Parameters
$fieldName : string
$options : array<string|int, mixed> = []
Tags
checked
noTodo
Return values
string

end()

Closes an HTML form, cleans up values set by FormHelper::create(), and writes hidden input fields where appropriate.

public end([array<string|int, mixed> $secureAttributes = [] ]) : string

Resets some parts of the state, shared among multiple FormHelper::create() calls, to defaults.

Parameters
$secureAttributes : array<string|int, mixed> = []

Secure attributes which will be passed as HTML attributes into the hidden input elements generated for the Security Component.

Tags
link
https://book.cakephp.org/4/en/views/helpers/form.html#closing-the-form
checked
noTodo
unitTest
Return values
string

A closing FORM tag.

file()

ファイルインプットボックス出力

public file(string $fieldName[, array<string|int, mixed> $options = [] ]) : string

画像の場合は画像タグ、その他の場合はファイルへのリンク そして削除用のチェックボックスを表示する

《オプション》 imgsize 画像のサイズを指定する rel A タグの rel 属性を指定 title A タグの title 属性を指定 link 大きいサイズへの画像へのリンク有無 delCheck 削除用チェックボックスの利用可否 force ファイルの存在有無に関わらず強制的に画像タグを表示するかどうか

Parameters
$fieldName : string
$options : array<string|int, mixed> = []
Tags
checked
noTodo
unitTest
Return values
string

getControlSource()

コントロールソースを取得する Model側でメソッドを用意しておく必要がある

public getControlSource(string $field[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>|false
Parameters
$field : string

フィールド名

$options : array<string|int, mixed> = []
Tags
checked
noTodo
unitTest
Return values
array<string|int, mixed>|false

コントロールソース

getId()

フォームのIDを取得する

public getId() : string

BcFormHelper::create() の後に呼び出される事を前提とする

Tags
checked
noTodo
unitTest
Return values
string

フォームID

getService()

Get Service

public getService( $service) : array<string|int, mixed>|mixed|object
Parameters
$service :
Tags
checked
noTodo
unitTest
Return values
array<string|int, mixed>|mixed|object

getTable()

フィールドに紐づくテーブルを取得する

public getTable(string $fieldName) : Table|false
Parameters
$fieldName : string
Tags
checked
noTodo
unitTest
Return values
Table|false

hasService()

Has Service

public hasService( $service) : bool
Parameters
$service :
Tags
checked
noTodo
unitTest
Return values
bool

prefTag()

都道府県用のSELECTタグを表示する

public prefTag(string $fieldName[, mixed $selected = null ][, array<string|int, mixed> $attributes = [] ][, array<string|int, mixed> $convertKey = false ]) : string
Parameters
$fieldName : string

Name attribute of the SELECT

$selected : mixed = null

Selected option

$attributes : array<string|int, mixed> = []

Array of HTML options for the opening SELECT element

$convertKey : array<string|int, mixed> = false

true value = "value" / false value = "key"

Tags
checked
noTodo
Return values
string

都道府県用のSELECTタグ

setId()

フォームのIDを設定する

public setId( $id) : string

BcFormHelper::create() の後に呼び出される事を前提とする

Parameters
$id :

フォームID

Tags
checked
noTodo
unitTest
Return values
string

新規フォームID

submit()

Creates a submit button element. This method will generate `<input />` elements that can be used to submit, and reset forms by using $options. image submits can be created by supplying an image path for $caption.

public submit([string $caption = null ][, array<string|int, mixed> $options = [] ]) : string

Options

  • div - Include a wrapping div? Defaults to true. Accepts sub options similar to FormHelper::input().
  • before - Content to include before the input.
  • after - Content to include after the input.
  • type - Set to 'reset' for reset inputs. Defaults to 'submit'
  • confirm - JavaScript confirmation message.
  • Other attributes will be assigned to the input element.

Options

  • div - Include a wrapping div? Defaults to true. Accepts sub options similar to FormHelper::input().
  • Other attributes will be assigned to the input element.
Parameters
$caption : string = null

The label appearing on the button OR if string contains :// or the extension .jpg, .jpe, .jpeg, .gif, .png use an image if the extension exists, AND the first character is /, image is relative to webroot, OR if the first character is not /, image is relative to webroot/img.

$options : array<string|int, mixed> = []

Array of options. See above.

Tags
link
https://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::submit
checked
noTodo
unitTest
Return values
string

A HTML submit button

createId()

フォームのIDを作成する BcForm::create より呼出される事が前提

protected createId(EntityInterface $context[, array<string|int, mixed> $options = [] ]) : string
Parameters
$context : EntityInterface
$options : array<string|int, mixed> = []
Tags
checked
noTodo
unitTest
Return values
string

        
On this page

Search results