定制 fewagency/twbs-blade 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fewagency/twbs-blade

最新稳定版本:v2.1.2

Composer 安装命令:

composer require fewagency/twbs-blade

包简介

Blade templates for Twitter Bootstrap

README 文档

README

This package is no longer maintained! Please see fewagency/fluent-form and fewagency/fluent-html for the replacements we use!

A collection of Laravel Blade templates for displaying Twitter Bootstrap html elements and components.

Configuration

Add this to your list of providers in config/app.php:

'FewAgency\TwbsBlade\TwbsBladeServiceProvider',

Usage examples

Single input field

Example:

@include('bsb::input.text', ['name'=>'test', 'label'=>'Your email address'])

Printing a full form

Example:

@include('bsb::form', ['action' => action('ExampleController@update', $model->getKey()), 'model' => $model, 'groups' => [
    'title' => ['label' => 'Name'],
    'content' => ['label' => 'Text', 'help_text' => 'This is displayed next to the input and connected to it with aria-describedby'],
    'number' => ['label' => "A number", 'type'=>'number'],
    'currency_code' => ['type' => 'select', 'label' => "Currency", 'options' => ['SEK' => 'Svenska kronor', 'GBP' => 'British Pounds']],
    '<button type="submit" class="btn btn-default">Save</submit>'
]])

Form options

Each form will contain a hidden csrf-field and by default display validation information next to each input.

groups

An array of inputs (or other elements) to display in the form. Array key is the input name and each entry is usually an array of input options.

An entry can also be a single string or a non-associative array of strings, and if so they are displayed as strings of html within a .form-group element.

model (optional)

If supplied, inputs will be pre-filled with corresponding attribute values from this object.

action (optional)

Maps directly to the form's action attribute. If omitted the form will usually post back to the current page.

method (optional)

Maps directly to the form's method attribute. Defaults to POST, can be set to GET.

role (optional)

Maps directly to the form's role attribute. Defaults to form.

form_id (optional)

Sets the form's id attribute. Defaults to a generated id if omitted.

group_form_errors (optional)

Defaults to false, but if true all error-messages will be displayed together at the top of the form instead of next to their related inputs. This is useful for forms where validation-messages are not directly related to specific inputs, e.g. login forms.

Input options

name

Name of the input, will be posted with the form. This option is pulled from the array key if the bsb::form template is used.

type

Defaults to text if omitted. The implemented types are:

  • text
  • checkbox
  • select
  • multiselect
  • password

In addition, most HTML5 input types work fine, e.g. number, email, etc. The multiselect types will automatically add brackets to the form input's name to access selected values as an array at the server side.

label/html_label

Displayed before the input and connected to it via element's id. Defaults to name if not supplied.

help_text/html_help_text

This is displayed after the input and connected to it with aria-describedby.

help_block_tag

This can override the type of html element that contains the help text. If not set span is used around help_text and div around html_help_text.

no_label

Set this to true to not display any label for the form-group.

group_label

Set this to true on checkboxes to display the group-label instead of having the label within the input-tag.

no_group

Set to true to not have a .form-group class on the input's grouping div. Useful for keeping a list of checkboxes closer together.

value

Can be used to specifically set the value attribute of the input. The value is usually automatically pulled from old input or from a model. The value defaults to 1 for checkboxes.

selected_values

Can be used with selects and multiselects to specify the pre-selected value or an array of pre-selected values. This is usually automatically pulled from old input or from a model.

checked

Set to true on a checkbox to make it pre-selected. Otherwise the checked-status is pulled from old input or from a model.

options/options_html

Can be used with selects and multiselects to specify the list of available options. options_html is used as raw output within the select tag. options can be an array of label strings with the corresponding values as keys. If no options are specified, the supplied model will be checked for a property called inputname_options.

input_attributes

Array of extra html attributes (keys and values) to put on the input element. Boolean attributes (like disabled) can be set to true for the desired effect. If the class attribute is set here it's value is merged with any other classes that have been set automatically.

Optional package configuration

The bsb prefix can be changed if you extend the service provider class in your app and set your desired $package_reference_name in there (if you do this, remember to reference your own service provider in your config/app.php instead of the one supplied by this package)

You may publish the blade templates to your project's views/vendor directory for editing and overriding the original templates:

php artisan vendor:publish --provider="FewAgency\TwbsBlade\TwbsBladeServiceProvider"

fewagency/twbs-blade 适用场景与选型建议

fewagency/twbs-blade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 113 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「bootstrap」 「laravel」 「blade」 「twbs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fewagency/twbs-blade 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fewagency/twbs-blade 我们能提供哪些服务?
定制开发 / 二次开发

基于 fewagency/twbs-blade 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 113
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-09