valksystems/bootbuilder
Composer 安装命令:
composer require valksystems/bootbuilder
包简介
Easy bootstrap form builder in OOP PHP. You can generate forms from object oriented form building with PHP code.
关键字:
README 文档
README
BootBuilder
Bootstrap Form Building made easy in PHP.
Installation
You can install the package with Composer, check out composer on http://getcomposer.org
Add the following to the required in the composer.json:
"valksystems/bootbuilder": ">=1.0.0"
Or execute the following composer command:
composer require 'valksystems/bootbuilder:1*'
Usage
Checkout the demo folder for demo's with the controls and different styles of forms
Forms
First of all, you have to create a Form object. There are 2 options right now. Just a normal form and a horizontal form (look at bootstrap page for more information).
To create a form use:
$form = BootBuilder::open(); // Horizontal Form $horizontal = BootBuilder::openHorizontal();
On the form object you can set the properties of a normal form with the following methods:
setAction($action) // Set the action attribute setClass($class) // set class (this will replace current class) setId($id) // set the id of the form setMethod($method) // set the method, either get or post
To add controls or panes to the form, use:
$form->add($control); // Or when adding multiple controls/panes at the same time: $form->addAll($pane1, $control, $submit);
HorizontalForm
On a horizontal form you can set 2 more parameters for the grid layout. To set the layout parameters, use the following methods:
$horizontal->setLabelCol($label_col) // for example col-md-3 $horizontal->setControlCol($control_col) // for example col-md-9
Rendering
To render the form you simply call render(). You can also get the rendered HTML back with render(true).
Controls
You can use the following controls, in fully bootstrap styles:
- Button
- Submit (Button)
- Checkbox
- Radio
- Text (input type=text)
- Number (input type=number)
- Email (input type=email)
- TextArea
- Hidden (input type=hidden)
- Password (input type=password)
- Select
Default operations on controls
To create a new control. Construct the class for the control with:
use \bootbuilder\Controls\Text; $text = new Text("name"); // Or you can directly give it a label, ID and value with the optional constructor parameters $text = new Text("name", "Please enter your name", "name_id", "Current Name");
On all the controls you can set the name, id, class(es), value, placeholder, label text, required (y/n), disabled (y/n), readonly (y/n), errorstate (y/n) and helptext with simple methods:
setId($id) // set the id of the control tag (<input>/<select>/etc) setClass($class), addClass($class), removeClass($class) // Edit the current class(es) setValue($value) // set the value of the control. (not filtered!!) setPlaceholder($placeholder) // set the placeholder setLabel($labeltext) // set the label text, for using when rendering in a supported form setRequired($required) // set if the control is required (note, browser can be manipulated) setDisabled($disabled) // set disabled state setReadOnly($readonle) // set readonly state setErrorState($errorstate) // set if the control is in error state setHelpText($helptext) // set helptext for under the control
After creating you can either add it to a pane or to the form directly.
Text
You can enter a custom type of input now, with the method setType($type)
TextArea
On a TextArea object you can set the optional rows parameter with the method setRows($rows)
Select
To set the data in the select control (the options), use the following method:
$options = array("key_value" => "Key Value"); setOptions($options);
The $options need to have an array with: [value] = "Readable text".
Panes
You can combine controls with panes, it's like an group with elements, but specific with the style it has. Currently there are 2 panes, StackPane and InlinePane
To create a pane and add controls to it use:
$pane = new StackPane("Label Here"); $pane->addControl($control); $form->add($pane);
StackPane
StackPane will combine elements, each on a new row. Just adding it below it.
InlinePane
InlinePane will make the supported controls (checkbox and radio) display with an in-line style. See http://getbootstrap.com/css/?#inline-checkboxes-and-radios for more information.
License
This project is under MIT License, see LICENSE file.
Resposibility
We are not resposible for any security problems, always check code before you are going to use it!
valksystems/bootbuilder 适用场景与选型建议
valksystems/bootbuilder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 61 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「bootstrap」 「builder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 valksystems/bootbuilder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 valksystems/bootbuilder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 valksystems/bootbuilder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
A Sphinx Query Builder extension for the Laravel Database package
Anax Database Active Record module for model classes.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
A Laravel Filament Forms slug field.
A simple package to create tables in Discord messages.
统计信息
- 总下载量: 61
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-25