PHPackages                             ilbronza/formfield - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ilbronza/formfield

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ilbronza/formfield
==================

:form\_field

1.0(3y ago)0297MITPHP

Since Sep 3Pushed 3w ago2 watchersCompare

[ Source](https://github.com/ilBronza/FormField)[ Packagist](https://packagist.org/packages/ilbronza/formfield)[ Docs](https://github.com/ilbronza/formfield)[ RSS](/packages/ilbronza-formfield/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

FormField
=========

[](#formfield)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e6debf292fe995659deb6c228f3b00d4b3467cef1898078fb1e47ca9f266ee96/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696c62726f6e7a612f666f726d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ilbronza/formfield)[![Total Downloads](https://camo.githubusercontent.com/cc34c7fe40ebd7632de61c464e608bcedee8ec81d1eeb0ae32c7f86a125d871e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696c62726f6e7a612f666f726d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ilbronza/formfield)[![Build Status](https://camo.githubusercontent.com/62dacb536967bab016848892c6d21d178cfe44b4451d4a46b79a45b91ef067ed/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f696c62726f6e7a612f666f726d6669656c642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ilbronza/formfield)[![StyleCI](https://camo.githubusercontent.com/cb13a877afd1dbe223c631789c3f922d3ace958fdb334a9cce9b26afefbc2ebd/68747470733a2f2f7374796c6563692e696f2f7265706f732f31323334353637382f736869656c64)](https://styleci.io/repos/12345678)

This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.

Installation
------------

[](#installation)

Via Composer

```
$ composer require ilbronza/formfield
```

Usage
-----

[](#usage)

### Select or multiple fields

[](#select-or-multiple-fields)

#### Set the possible values for a relation

[](#set-the-possible-values-for-a-relation)

Given a relation (ex. Categories) you can set the possible values for a select or multiple field with the following code to populate the select or multiple field options

```
public function getPossibleClientsValuesArray() : array
{
    return Category::select('name', 'id')->take(10)->pluck('name', 'id')->toArray();
}
```

Batch field refresh (chiamata cumulativa)
-----------------------------------------

[](#batch-field-refresh-chiamata-cumulativa)

I campi del form che vanno riletti dal server dopo un salvataggio (editor inline, save di riga in tabella, `fetchFieldValue`) non vengono più richiesti con una chiamata HTTP per campo: vengono accodati e richiesti con **una sola POST cumulativa**.

Il sistema è composto da tre pezzi:

PacchettoRuolo**FormField** (`ilbronza.formfields.batch.js`)coordinatore JS: coda, dedup, debounce, chiamata batch, applicazione valori al DOM**Crud** (`CRUDUpdateEditorBatchReadTrait`)endpoint batch: legge N campi dal modello in una richiesta**datatables**hook su `draw.dt` e su save riga che innescano il refresh### Come funziona

[](#come-funziona)

1. Qualcuno chiede il refresh di uno o più campi (per nome).
2. Il coordinatore accoda i nomi in un `Set` per URL editor (`data-updateeditorurl`), deduplicandoli.
3. Dopo un debounce di 50ms parte **una** POST sulla route di update del modello con:

```
ib-editor-read-batch: true
fields[]: total_cost
fields[]: total_revenue
_method: PUT

```

4. La risposta contiene tutti i valori:

```
{
    "success": true,
    "fetch-fields-batch": true,
    "values": { "total_cost": 123.45, "total_revenue": 456.78 },
    "model-id": "..."
}
```

5. Il coordinatore applica ogni valore al campo corrispondente (gestendo date, cleave/money, checkbox/radio, `originalvalue`, trigger `ibchanged`) senza scatenare salvataggi automatici.

### API JavaScript

[](#api-javascript)

```
// accoda campi per il refresh (debounce + dedup), una POST per URL
window.requestFieldsRefreshBatch(['total_cost', 'total_revenue']);
window.requestFieldsRefreshBatch(['total_cost'], { url: '...', debounceMs: 100 });

// singolo campo
window.requestFieldRefreshBatch('total_cost');

// esegue subito la coda di una URL senza aspettare il debounce
window.flushFieldsRefreshBatch(url);

// chiamata diretta senza coda (ritorna jqXHR)
window.getFieldsValuesFromEditorBatch(['total_cost'], url);

// equivalente batch di refreshFetchingFieldsValues (legge data-fetchfields dal target)
window.refreshFetchingFieldsValuesBatch(target);

// equivalente batch di dtRefreshFieldsList (risolve i selettori di
// window.dtEditorRefreshingFieldList in nomi campo)
window.dtRefreshFieldsListBatch();
```

### Entry point pubblici (retrocompatibili)

[](#entry-point-pubblici-retrocompatibili)

Le funzioni storiche restano e ora passano dal batch:

- `getFieldValueFromEditor(target)` → `requestFieldRefreshBatch`
- `refreshFetchingFieldsValues(target)` → `refreshFetchingFieldsValuesBatch`
- `dtRefreshFieldsList()` (datatables) → `dtRefreshFieldsListBatch`

Le implementazioni a chiamata singola sono sospese ma disponibili come fallback: `__ibLegacyGetFieldValueFromEditor`, `__ibLegacyRefreshFetchingFieldsValues`, `__ibLegacyDtRefreshFieldsList`.

### Dichiarare le dipendenze (lato PHP, invariato)

[](#dichiarare-le-dipendenze-lato-php-invariato)

Nei fieldset si continua a usare `fetchFieldValue` per dire "quando questo campo viene salvato, rileggi questi altri":

```
'starts_at' => [
    'type' => 'date',
    'fetchFieldValue' => [
        'calculated_production_days',
        'calculated_event_days',
    ],
],
```

Il campo viene renderizzato con `data-fetchfields`; al salvataggio i campi elencati vengono riletti **in un'unica chiamata**.

### Requisiti

[](#requisiti)

- Il controller del modello deve usare `CRUDUpdateTrait` (Crud), che include `CRUDUpdateEditorBatchReadTrait`.
- I campi target devono avere `data-updateeditorurl` (renderizzato automaticamente da `__attributes.blade.php`).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance62

Regular maintenance activity

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~248 days

Total

4

Last Release

1382d ago

Major Versions

0.3 → 1.02022-09-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/33c65523e8a1cdfe8ed5f5fb8d90101b28eceb8c2ef7acb50a24cf6c42b8e639?d=identicon)[ilBronza](/maintainers/ilBronza)

---

Top Contributors

[![bronza](https://avatars.githubusercontent.com/u/3426331?v=4)](https://github.com/bronza "bronza (109 commits)")[![ilBronza](https://avatars.githubusercontent.com/u/68387610?v=4)](https://github.com/ilBronza "ilBronza (16 commits)")[![vadymydav](https://avatars.githubusercontent.com/u/1552274?v=4)](https://github.com/vadymydav "vadymydav (5 commits)")[![lbortolon](https://avatars.githubusercontent.com/u/109848849?v=4)](https://github.com/lbortolon "lbortolon (3 commits)")

---

Tags

laravelformfield

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ilbronza-formfield/health.svg)

```
[![Health](https://phpackages.com/badges/ilbronza-formfield/health.svg)](https://phpackages.com/packages/ilbronza-formfield)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20619.4k](/packages/stephenjude-filament-blog)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11273.0k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
