ride / lib-form
Ride框架的表单库
1.2.0
2024-06-26 08:35 UTC
Requires
- ride/lib-common: ^1.0.0
- ride/lib-image: ^1.0.0
- ride/lib-reflection: ^1.0.0
- ride/lib-system: ^1.0.0
- ride/lib-validation: ^1.0.0
- dev-master
- 1.2.0
- 1.1.0
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.14.11
- 0.14.10
- 0.14.9
- 0.14.8
- 0.14.7
- 0.14.5
- 0.14.4
- 0.14.3
- 0.14.2
- 0.14.1
- 0.14.0
- 0.13.0
- 0.12.13
- 0.12.12
- 0.12.11
- 0.12.10
- 0.12.9
- 0.12.8
- 0.12.7
- 0.12.6
- 0.12.5
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.1
- 0.11.0
- 0.10.0
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.8
- 0.6.7
- 0.6.6
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.7
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.2
- 0.1.1
- 0.1.0
- dev-develop
This package is auto-updated.
Last update: 2024-08-26 09:04:54 UTC
README
Ride PHP框架的表单库。
库中包含的内容
RowFactory
使用 RowFactory 接口可以根据简单名称创建一个 Row。使用此工厂增加了表单的灵活性,因为如果需要,每个行都可以用另一个实现覆盖。
GenericRowFactory 类提供了默认实现。
Row
使用 Row 接口来实施行类型。这可以是一个标量类型,如字符串、数字等,所有通用HTML表单元素。它也可以是一个组件或组件集合。
此库提供的以下行
- button
- collection
- component
- date
- file
- hidden
- image
- label
- number
- object
- option
- password
- select
- string
- text
- time
- website
- wysiwyg
Component
使用 Component 接口可以将多个行的组合分组为单个行或表单。例如,日期时间组件可以将日期行和时间行组合成一个行。创建组件将增加您表单的可重用性。
Widget
使用 Widget 接口来显示 Row。某些行可以有相同的逻辑但不同的视图表示。考虑一个选项行,它可以表示为复选框列表(或单选按钮)或选择字段。
View
使用 View 接口将表单发送到UI。它删除了构建表单所需的所有内容,并确保表单可序列化。
代码示例
查看此代码示例以了解此库的一些可能性
<?php function createForm(Form $form) { // id of the form $form->setId('form-example'); // action to catch submission of different forms on one page $form->setAction('submit-example'); $form->addRow('name', 'string', array( 'label' => 'Name', 'description' => 'Enter your name', 'filters' => array( 'trim' => array(), ), 'validators' => array( 'required' => array(), ), )); $form->addRow('gender', 'option', array( 'label' => 'Gender', 'description' => 'Select your gender', 'default' => 'F', 'options' => array( 'F' => 'Female', 'M' => 'Male', 'O' => 'Other', ), 'validators' => array( 'required' => array(), ), )); $form->addRow('extra', 'string', array( 'label' => 'Extra', 'description' => 'Extra row to show off some other options', 'multiple' => true, 'disabled' => false, 'readonly' => false, 'attributes' => array( 'data-extra' => 'An extra attribute for the HTML element', ), )); return $form->build(); }
相关模块
- ride/app-form
- ride/lib-common
- ride/lib-image
- ride/lib-reflection
- ride/lib-system
- ride/lib-validation
- ride/web-form
- ride/web-form-taxonomy
- ride/web-form-wysiwyg-ckeditor
- ride/web-form-wysiwyg-tinymce
安装
您可以使用 Composer 来安装此库。
composer require ride/app-form