dekyfin / php-array-forms
该包的最新版本(0.3)没有提供许可证信息。
一个用于从PHP数组创建HTML表单的包
0.3
2018-01-24 09:49 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-15 05:28:44 UTC
README
一个允许您使用PHP数组创建HTML表单的库。该项目受到了Titan框架的启发,并使用相同的格式生成元素
安装
Composer
composer require dekyfin/php-array-forms
直接安装
##用法 - 包含 DF\ArrayForm
类 --Composer: require_once "vendor/autoload.php"
--直接安装: require_once "path/to/ArrayForm.php"
示例
#Attributes to be used for the form
$formData = [
"action" => "/path/to/form/processor.php",
"method" => "post",
"class" => "my-special-form",
"id" => "myForm",
"display" => "table"
];
$elements = [
[
"id" => "email",
"name" => "Email",
"type" => "email"
"required" => true,
],
[
"id" => "pass",
"name" => "Password",
"type" => "password",
"required" => true,
],
[
"id" => "amount",
"name" => "Amount",
"type" => "number",
"step" => "0.01",
"min" => "3",
],
[
"id" => "payment[method]",
"name" => "Payment Method",
"type" => "select",
"options" => ["true", "false"],
]
];
$form = DF\ArrayForm( $formData, $elements );
$html = $form->$build();
echo $html