klapuch/form

此包已被废弃且不再维护。未建议替换包。
关于此包最新版本(5.4.0)没有提供任何许可信息。

多种格式的高度可定制的表单

5.4.0 2017-05-26 17:07 UTC

This package is auto-updated.

Last update: 2020-11-14 01:58:09 UTC


README

Build Status Build status Coverage Status

文档

安装

composer require klapuch/form

使用方法

表单

new Form\RawForm(
	[
		'method' => 'POST',
		'role' => 'form',
		'class' => 'form-horizontal',
		'action' => '/process.php',
		'name' => self::NAME,
	],
	new Form\CsrfInput($this->csrf)
);

带选项的选择框

new Form\Select(
	new Form\FakeAttributes(['name' => 'fruit']),
	new Form\Option(
		new Form\DependentAttributes(['value' => 'apple'], $this->storage, 'fruit'),
		'Apple',
		new Validation\OneOfRule(['apple', 'berry'])
	),
	new Form\Option(
	new Form\DependentAttributes(['value' => 'berry'], $this->storage, 'fruit'),
	'Berry',
	new Validation\OneOfRule(['apple', 'berry'])
	)
);

带标签的输入框

new Form\BoundControl(
	new Form\Input(
		new Form\StoredAttributes(
			[
				'type' => 'email',
				'name' => 'email',
				'class' => 'form-control',
				'required' => 'required',
			],
			$this->storage
		),
		new Constraint\EmailRule()
	),
	new Form\LinkedLabel('Email', 'email')
);