david-cova/cova-forms
Composer 安装命令:
composer require david-cova/cova-forms
包简介
Customizable inputs, forms, buttons etc.
README 文档
README
This is a guide to help you interact with the include blade directive from laravel to pass variables to form inputs to minimize time required and faulty forms.
Publishing assets
Views
php artisan vendor:publish --tag=cova-forms
Livewire components
php artisan vendor:publish --tag=cova-livewire
Example
<form action="{{route('training.store')}}" method="post"> @csrf @include('blocks.forms.errors') @include('blocks.forms.input-text', ['identifier' => "name",'label' => "Name",'required' => 'required']) @include('blocks.forms.input-text', ['identifier' => "speaker",'label' => "Speaker",'required' => 'required']) @include('blocks.forms.input-text', ['identifier' => "price",'label' => "Price",'required' => 'required']) @include('blocks.forms.input-number', ['identifier' => "hours",'required' => 'required']) @include('blocks.forms.input-select', ['identifier' => "type",'label' => "Type",'required' => 'required','options' => ['Hard Skills','Soft Skills']]) @include('blocks.forms.input-money', ['identifier' => "total_avg_admission_cost",'label' => 'total','required' => 'required','readonly' => 'readonly','step' => '0.01']) @include('blocks.forms.input-date', ['identifier' => "from",'label' => "From",'required' => 'required','min' =>Carbon\Carbon::now('Europe/Lisbon')->format('Y-m-d'),'max' => ""]) @include('blocks.forms.input-date', ['identifier' => "to",'label' => "To",'required' => 'required','min' =>Carbon\Carbon::now('Europe/Lisbon')->format('Y-m-d'),'max' => ""]) @include('blocks.forms.input-select', ['identifier' => "status",'required' => 'required','options' => ['Expired','Finished','Ongoing','Registered']]) @include('blocks.forms.input-select', ['identifier' => "company",'required' => 'required','options' => $companies,'key' => 'id','val' => "name"]) @include('blocks.forms.input-select-multiple', ['identifier' => "employees",'label' => "Employees",'required' => 'required','options' => $employees,'key' => 'id','val' => "known_name"]) @include('blocks.forms.input-textarea', ['identifier' => "body",'label' => 'Description','required' => 'required','cols' => 60,'rows'=>1]) @include('blocks.forms.input-hidden', ['identifier' => 'employee_id','val' => $employee->id,'required' => 'required']) @include('blocks.forms.input-select', ['identifier' => "status",'required' => 'required','options' => json_encode([['id' => 1,'name' => 'Active'],['id' => 0,'name' => 'Inactive']]),'key' => 'id','val' => "name"]) @include('blocks.forms.input-file', ['identifier' => 'file_path[]','label' => 'Documents','multiple' => 'multiple','filetypes' => ['application/pdf','.doc','.docx']]) <div class="py-2"> @include('blocks.buttons.submit-create') </div>
@include('blocks.forms.input-text', ['identifier' => "position",'label' => "Job position",'required' => 'required']) @include('blocks.forms.input-select', ['identifier' => "company",'required' => 'required','options' => $companies,'key' => 'id','val' => "name"]) @include('blocks.forms.input-select', ['identifier' => "type",'required' => 'required','options' => ['Full-time','Permanent Contract','Temporary','Part-time','Volunteer','Internship']]) @include('blocks.forms.input-select', ['identifier' => "experience",'required' => 'required','options' => ['Entry level','Associate','Senior','Internship','Director','Executive']]) @include('blocks.forms.input-select', ['identifier' => "remote",'label' => 'Remote Work','required' => 'required','options' => json_encode([['id' => 1,'name' => 'Yes'],['id' => 0,'name' => 'No'],['id' => 2,'name' => 'Mixed']]),'key' => 'id','val' => "name"]) @include('blocks.forms.input-select', ['identifier' => "status",'required' => 'required','options' => json_encode([['id' => 1,'name' => 'Active'],['id' => 0,'name' => 'Inactive']]),'key' => 'id','val' => "name"]) @include('blocks.forms.input-text', ['identifier' => "location",'required' => 'required']) </form>
@include('blocks.buttons.submit-create') @include('blocks.buttons.submit-send') @include('blocks.buttons.submit-delete') @include('blocks.buttons.submit-edit') @include('blocks.buttons.submit-update') @include('blocks.buttons.submit')
File input
Attributes
- identifier
- label
- filetypes
- multiple
- required
Multiple
When multiple is used, make sure to call the identifier as an array as such:
'identifier' => 'file_path[]','multiple' => 'multiple'
Also make sure the form as the correct enctype="multipart/form-data"
Filetypes
Filetypes can be defined as such:
'filetypes' => ['application/pdf','.doc','.docx'] 'filetypes' => ['image/jpeg,image/gif,image/png,application/pdf'] 'filetypes' => ['jpg,png,jpeg,PNG,JPEG,JPG,GIF,gif']
Select input example
Using json_encode
@include('blocks.forms.input-select',[ 'identifier' => 'fruits_types', 'label' => 'Fruits', 'options' => json_encode( [ ['id' => 0,'name' => 'Apple'], ['id' => 1,'name' => 'Banana'], ['id' => 2,'name' => 'Cherry'], ['id' => 3,'name' => 'Dragon Fruit'], ['id' => 4,'name' => 'Elder Berry'], ['id' => 5,'name' => 'Fig'], ] ), 'key' => 'id', 'value' => 'name', 'current' => $basket->favorite_fruit ])
Livewire live update inputs
Usage example
Input File
<div class="mt-2">Finance File</div> @livewire('updater-file', [ 'col' => 'finance_file', 'model' => $investor, 'rules' => ['file','max:1024'], 'save_path' => 'people/'.$person->id.'-'.str_replace(' ', '-', strtolower($person->name)).'/investor/'.$investor->id.'' ])
Input Number
@livewire('updater-number', [ 'col' => 'investment_performance', 'current' => $investor->investment_performance, 'model' => $investor, 'step' => 0.01 ])
Input Text
@livewire('updater-text', [ 'col' => 'motivation', 'current' => $investor->motivation, 'model' => $investor ])
Select
@livewire('updater-select', [ 'col' => 'ownership', 'current' => $investor->ownership, 'model' => $investor, 'label' => false, 'options' => ['Full','Partnership'] ])
david-cova/cova-forms 适用场景与选型建议
david-cova/cova-forms 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Forms」 「inputs」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 david-cova/cova-forms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 david-cova/cova-forms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 david-cova/cova-forms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
ConfirmationField is a form field for Atk14 applications. It's like the BooleanField (checkbox) but the ConfirmationField must be ticked.
Field for number with restricted count of digits and decimal places
Livewire starter kit for Lunar e-commerce.
MvcCore - Extension - Form - form extension with base classes to create and render web forms with HTML5 controls, to handle and validate submited user data, to manage forms sessions for default values, to manage user input errors and to extend and develop custom fields and field groups.
HTML and form generation
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-30