grottopress / form-field
渲染HTML表单字段
v1.0.0
2023-05-31 15:45 UTC
Requires
- php: >=7.0
- grottopress/getter: ^1.0
- laminas/laminas-escaper: ^2.6
Requires (Dev)
README
渲染HTML表单字段。
使用方法
通过composer安装
composer require grottopress/form-field`
实例化和使用如下
<?php declare (strict_types = 1); use GrottoPress\Form\Field; // Text field $text = new Field([ 'id' => 'field-id', 'name' => 'field-name', 'type' => 'text', 'value' => 'My awesome text field', 'label' => 'My text field', ]); // Render text field echo $text->render(); // Radio buttons $radio = new Field([ 'id' => 'field-id', 'name' => 'field-name', 'type' => 'radio', 'value' => 'my-choice', 'choices' => [ 'one' => 'One', 'my-choice' => 'My Choice', 'two' => 'Two', ], ]); // Render radio field echo $radio->render(); // Dropdown $dropdown = new Field([ 'id' => 'field-id', 'name' => 'field-name', 'type' => 'select', 'value' => 'my-choice', 'choices' => [ 'one' => 'One', 'my-choice' => 'My Choice', 'two' => 'Two', ], ]); // Render dropdown field echo $dropdown->render(); // Multi-select dropdown $mdrop = new Field([ 'id' => 'field-id', 'name' => 'field-name[]', 'type' => 'radio', 'value' => 'my-choice', 'choices' => [ 'one' => 'One', 'my-choice' => 'My Choice', 'two' => 'Two', ], 'meta' => [ 'multiple' => 'multiple', ], ]); // Render multi-select dropdown echo $mdrop->render();
开发
使用composer run test
运行测试。
贡献
- 进行Fork
- 切换到
master
分支:git checkout master
- 创建你的功能分支:
git checkout -b my-new-feature
- 进行更改,根据需要更新变更日志和文档。
- 提交你的更改:
git commit
- 推送到分支:
git push origin my-new-feature
- 向
GrottoPress:master
分支提交一个新的Pull Request。