mhriad/laravel-form 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mhriad/laravel-form

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mhriad/laravel-form

包简介

A lightweight Laravel Form Builder for Laravel 10, 11 & 12 (replacement for LaravelCollective Form).

README 文档

README

A lightweight, drop-in Form Builder for Laravel 10 & 11 — a safe, minimal replacement for the LaravelCollective Form:: API. It provides common Form:: helpers (open, close, text, email, password, textarea, select, checkbox, radio, file, submit, etc.) so you can keep your existing Blade views without rewriting forms.

What does this package do?

This package implements a small, focused Form Builder that:

  • Recreates the most commonly used features of LaravelCollective\Form using the same facade/API style (Form::...) so existing Blade templates continue working.
  • Automatically handles CSRF tokens, HTTP method spoofing (PUT/PATCH/DELETE), and multipart/form-data for file uploads.
  • Supports:
    • Basic inputs: text, email, number, password, hidden
    • textarea, file
    • select (arrays & collections)
    • checkbox, radio
    • submit, reset
  • Provides old() value handling, simple model binding via Form::model(), and safe HtmlString output.
  • Helps large projects upgrade Laravel versions (10/11) without rewriting forms.

Benefits of using this package

  • Zero view changes — keep using Form::open, Form::text, etc.
  • Laravel 10/11 compatible — works with modern PHP versions.
  • Lightweight & dependency-free.
  • Secure — auto-escapes values & inserts CSRF/method fields.
  • Extendable — easy to customize.
  • Safe migration path for legacy projects.

Installation

Requirements:

  • PHP ≥ 8.1
  • Laravel 10 or 11

Install: composer require mhriad/laravel-form

Clear caches: composer dump-autoload php artisan optimize:clear

Usage Examples

Simple form

  • {!! Form::open(['route' => 'users.store', 'method' => 'post', 'class' => 'form-horizontal']) !!}

  • {!! Form::text('first_name', old('first_name'), ['class' => 'form-control']) !!}

  • {!! Form::text('last_name', old('last_name'), ['class' => 'form-control']) !!}

  • {!! Form::email('email', old('email'), ['class' => 'form-control']) !!}

  • {!! Form::select('plan_id', \App\Models\SubscriptionsPlan::pluck('name','id'), null, ['class' => 'form-control select2']) !!}

  • {!! Form::file('avatar') !!}

  • {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}

  • {!! Form::close() !!}

Model binding

Controller: $user = User::find(1); return view('users.edit', compact('user'));

Blade: {!! Form::model($user) !!} {!! Form::text('name') !!} {!! Form::email('email') !!} {!! Form::close() !!}

API Reference

Form::open() Form::close() Form::model() Form::text() Form::email() Form::password() Form::hidden() Form::file() Form::textarea() Form::select() Form::checkbox() Form::radio() Form::submit() Form::reset()

License

MIT License.

Author

M H Riad — https://github.com/mhriad

Next version planned: label(), selectRange(), selectYear(), date(), macros, etc.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-04