typicms/laravel-translatable-bootforms
Composer 安装命令:
composer require typicms/laravel-translatable-bootforms
包简介
Empowers typicms/bootforms with typicms/laravel-translatable.
README 文档
README
Make BootForms work flawlessly with Laravel Translatable!
By importing this package, generating translatable forms using BootForms is a breeze.
Installation
-
Run the Composer require command to install the package, the service provider will be autodiscovered by Laravel.
composer require typicms/laravel-translatable-bootforms -
In your app config, add the Facade to the
$aliasesarray'aliases' => [ ... 'TranslatableBootForm' => TypiCMS\LaravelTranslatableBootForms\Facades\TranslatableBootForm::class, ],
-
Publish the configuration file
php artisan vendor:publish --provider="TypiCMS\LaravelTranslatableBootForms\TranslatableBootFormsServiceProvider" --tag="config"
Usage
Simply use the TranslatableBootForm Facade as if it were BootForm! That’s it. Multiple form inputs will now be generated for the locales set in Translatable’s configuration file. They will have the corresponding value for each language and will save all of the translations without any code manipulation.
Please review BootForms’ documentation if you’re unsure how to use it.
Example:
// View {!! BootForm::text('Name', 'name') ->placeholder('My placeholder') !!} // Output <div class="form-group"> <label for="name">Name</label> <input type="text" name="name" class="form-control" placeholder="My Placeholder"> </div> // Controller public function postEdit($request) { $someModel->save($request->all()); }
// View {!! TranslatableBootForm::text('Name', 'name') ->placeholder('My placeholder') !!} // Output <div class="form-group form-group-translation"> <label for="name[en]">Name (en)</label> <input type="text" name="name[en]" class="form-control" placeholder="My Placeholder" data-language="en"> </div> <div class="form-group form-group-translation"> <label for="name[nl]">Name (nl)</label> <input type="text" name="name[nl]" class="form-control" placeholder="My Placeholder" data-language="nl"> </div> // Controller public function postEdit($request) { $someModel->save($request->all()); }
You can use the %name and %locale placeholders while specifying parameters. The placeholder will be replaced with the corresponding input name or locale.
This can be useful for two-way data binding libraries such as Angular.js or Vue.js. E.g.
{!! TranslatableBootForm::text('Title', 'title')
->attribute('some-attribute', 'Name: %name')
->attribute('another-attribute', 'Locale: %locale') !!}
// Output
<div class="form-group form-group-translation">
<label for="title[en]">Title (en)</label>
<input type="text" name="title[en]" class="form-control" some-attribute="Name: title[en]" another-attribute="Locale: en" data-language="en">
</div>
<div class="form-group form-group-translation">
<label for="title[nl]">Title (nl)</label>
<input type="text" name="title[nl]" class="form-control" some-attribute="Name: title[nl]" another-attribute="Locale: nl" data-language="nl">
</div>
To render a form element only for some chosen locales, explicitly call renderLocale() as the final method and pass the locale or an array of locales as the first parameter:
TranslatableBootForm::text('Name', 'name') ->renderLocale('en')
If you need to apply a method only for certain locales, suffix the method with ForLocale and pass the locale or an array of locales as the first parameter:
TranslatableBootForm::text('Name', 'name') ->dataForLocale('en', 'attributeName', 'attributeValue') ->addClassForLocale(['en', 'nl'], 'addedClass')
For customizing the locale indicator in the label (and several other settings), please take a look at the configuration file.
typicms/laravel-translatable-bootforms 适用场景与选型建议
typicms/laravel-translatable-bootforms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31.38k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「i18n」 「form」 「translatable」 「laravel」 「bootforms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 typicms/laravel-translatable-bootforms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 typicms/laravel-translatable-bootforms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 typicms/laravel-translatable-bootforms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use i18n translation PHP class for multi-language websites
A custom URL rule class for Yii 2 which allows to create translated URL rules
A Laravel Eloquent model trait for translatable resource
An Astrotomic Translatable extension for Laravel Nova.
Doctrine2 behavior traits - slowhop fork
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.
统计信息
- 总下载量: 31.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 6
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-15