定制 dragan/form-components 二次开发

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

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

dragan/form-components

最新稳定版本:1.0.2

Composer 安装命令:

composer require dragan/form-components

包简介

Laravel x-blade form components for easy usage

README 文档

README

A PHP library for managing and rendering form components.

Installation

Install the package using Composer:

composer require dragan/form-components

Features

  • Easy-to-use form components for Laravel applications.
  • Supports various form fields such as text, email, password, textarea, select, checkbox, radio, and file input.
  • Automatic handling of old input values.
  • Supports form model binding.
  • Customizable attributes for each form field.

Usage

Form opening and closing

The form::open component is used to create a form. It accepts various attributes such as method, action, and enctype.

<x-form::open method="POST" action="/submit">
    <x-form::text name="name" label="Name" required />
    <x-form::email name="email" label="Email" type="email" required />
    <x-form::textarea name="message" label="Message" required />
    
    <x-form::input name="submit" type="submit" value="Submit" />
</x-form::open>

Form model

The form::model component can also be used with a model. This allows you to bind the form fields to the model's attributes. You can provide array, object, or collection data to the form.

<x-form::model method="POST" action="/submit" :model="$user">
    <x-form::text name="name" label="Name" required />
    <x-form::email name="email" label="Email" type="email" required />
    <x-form::textarea name="message" label="Message" required />
    
    <x-form::input name="submit" type="submit" value="Submit" />
</x-form::model>

Form fields

The library provides various form fields such as text, email, password, textarea, select, checkbox, radio, and file input. Each field can be customized with attributes like name, label, value, placeholder, and more.

Text input

<x-form::text name="username" label="Username" placeholder="Enter your username" required />

Email input

<x-form::email name="email" label="Email" placeholder="Enter your email" required />

Password input

<x-form::password name="password" label="Password" placeholder="Enter your password" required />

Textarea

<x-form::textarea name="message" label="Message" placeholder="Enter your message" required />

Select

<x-form::select name="country" label="Country" :options="$countries" required />

Checkbox

<x-form::checkbox name="terms" label="I agree to the terms and conditions" required />

Old input values

The library automatically handles old input values. If the form is submitted and validation fails, the old input values will be repopulated in the form fields. This is done using the old() helper function in Laravel.

Contributing

If you would like to contribute to this library, please fork the repository and submit a pull request. We welcome contributions of all kinds, including bug fixes, new features, and documentation improvements.

License

This library is licensed under the MIT License. See the LICENSE file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固