PHPackages                             ramaid/hypervel-formstate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. ramaid/hypervel-formstate

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

ramaid/hypervel-formstate
=========================

Reusable form state handling and validation redirect macros for Hypervel.

01PHPCI failing

Since Jul 9Pushed 10mo agoCompare

[ Source](https://github.com/ramaID/hypervel-form-state)[ Packagist](https://packagist.org/packages/ramaid/hypervel-formstate)[ RSS](/packages/ramaid-hypervel-formstate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

🧰 FormState for Hypervel
========================

[](#-formstate-for-hypervel)

[![Tests](https://github.com/ramaid/formstate/workflows/Tests/badge.svg)](https://github.com/ramaid/formstate/actions)[![Static Analysis](https://github.com/ramaid/formstate/workflows/Static%20Analysis/badge.svg)](https://github.com/ramaid/formstate/actions)[![Latest Stable Version](https://camo.githubusercontent.com/b1c3632f9a5db6327429f61582801ab4b44211bd3da09ec5df5e79121075502c/68747470733a2f2f706f7365722e707567782e6f72672f72616d6169642f666f726d73746174652f762f737461626c65)](https://packagist.org/packages/ramaid/formstate)[![Total Downloads](https://camo.githubusercontent.com/1a2220af766434b3f038969bb5cb8e0f79469b09817f72e254c4bce9409c222f/68747470733a2f2f706f7365722e707567782e6f72672f72616d6169642f666f726d73746174652f646f776e6c6f616473)](https://packagist.org/packages/ramaid/formstate)[![License](https://camo.githubusercontent.com/1bb40ba58e563ec2312b487c488885e83e40e2a407688eefc2672ae27adbea24/68747470733a2f2f706f7365722e707567782e6f72672f72616d6169642f666f726d73746174652f6c6963656e7365)](https://packagist.org/packages/ramaid/formstate)

Standardized form error and input state handling for Hypervel apps.

✨ Features
----------

[](#-features)

- 📝 Automatically shares `old` input and `errors` in all Blade views
- 🔧 Provides `FormState::errors()`, `::old()`, `::value()` helpers
- 🚀 Adds `response()->withValidationErrors()` macro
- 📋 Custom `BaseFormRequest` class with error helpers (`old()`, `error()`, `hasError()`)
- 🎨 **NEW**: Blade directive macros (`@formError`, `@formValue`, etc.)
- ⚡ **NEW**: Artisan generator command (`make:form-request`)
- ✅ **NEW**: Comprehensive test suite with PHPUnit
- 🔍 **NEW**: Static analysis with PHPStan and code formatting with PHP CS Fixer

📦 Installation
--------------

[](#-installation)

```
composer require ramaid/formstate
```

🚀 Usage
-------

[](#-usage)

### Controller

[](#controller)

```
use App\Http\Requests\LoginRequest;

public function store(LoginRequest $request)
{
    $validator = Validator::make($request->all(), [...]);

    if ($validator->fails()) {
        return response()->withValidationErrors($validator);
    }
}
```

### Blade Templates

[](#blade-templates)

#### Traditional Way

[](#traditional-way)

```

@if ($request->hasError('email'))
    {{ $request->error('email') }}
@endif
```

#### Using New Blade Directives

[](#using-new-blade-directives)

```

@formError('email')

@formInput('email', 'email', 'form-input')

@hasFormError('email')

        @formError('email')

@endhasFormError
```

### BaseFormRequest

[](#baseformrequest)

```
use Ramaid\FormState\Http\Requests\BaseFormRequest;

class LoginRequest extends BaseFormRequest
{
    public function rules(): array
    {
        return [
            'email' => 'required|email',
            'password' => 'required|min:8',
        ];
    }

    public function messages(): array
    {
        return [
            'email.required' => 'We need your email address!',
        ];
    }
}
```

### 🎯 Artisan Generator

[](#-artisan-generator)

Generate form request classes easily:

```
# Basic form request
php artisan make:form-request LoginRequest

# Nested form request
php artisan make:form-request Auth/RegisterRequest
```

This creates a properly structured form request extending `BaseFormRequest`:

```
