anomaly/slider-field_type
Anomaly Slider Field Type provides a configurable slider input for Streams Platform forms and entries, letting editors select numeric values with defined range and step settings. It integrates smoothly into Laravel/PHP projects built on Anomaly CMS.
anomaly/slider-field_type is a Streams Platform field type addon, not a standalone slider library. It registers a "Slider" field type in the control panel so you can assign a range/step widget to a stream field. If you are not running PyroCMS / Streams, this package is not useful to you — the real dependency is anomaly/streams-platform.
Install with Composer and let addon discovery pick it up:
composer require anomaly/slider-field_type
php artisan addon:publish # publish views/assets if the addon ships them
Look here first:
| Path | Why |
|---|---|
src/SliderFieldType.php |
The field type class; $inputView, defaults, and validation live here |
resources/views/input.twig |
The actual <input type="range"> / JS widget markup |
resources/config/config.php or config/ |
Default min, max, step, unit/suffix keys |
lang/en/addon.php |
Name/description shown in the admin type picker |
First use case: in the control panel, open a stream → Fields → Assign Field, choose Slider, and set min/max/step in the field config. The stored value comes back as a plain number on the entry.
Preferred for one-off streams. The field config block (min, max, step, default) is persisted as JSON on the field assignment, so different streams can use the same field type with different ranges without touching code.
For repeatable deploys, define the field on the stream/migration so it's versioned:
protected $fields = [
'priority' => [
'type' => 'anomaly.field_type.slider',
'config' => [
'min' => 0,
'max' => 10,
'step' => 1,
],
],
];
If you prefer explicit calls, $stream->getAssignment('priority') / the FieldsRepository can be used to add the assignment in a seeder.
The value is a scalar, so treat it like any numeric attribute:
$entry->priority = 7;
$entry->save();
echo $entry->priority; // 7
In Twig:
<span class="badge">{{ entry.priority }}/10</span>
{# Simple star rendering from a 1–5 slider #}
{% for i in 1..5 %}
<i class="fa fa-star{{ i <= entry.rating ? '' : '-o' }}"></i>
{% endfor %}
Because it's a field type, it works anywhere Streams builds a form — the stream form, a custom module form that declares the field, or the FormBuilder:
$form->add('satisfaction', 'anomaly.field_type.slider', [
'config' => ['min' => 0, 'max' => 5, 'step' => 1],
]);
Store the raw number and convert on read rather than storing display strings. Keep the slider as the input control and put labels ("Low/Medium/High") in Twig or a view presenter — the field type only knows about numbers.
anomaly/streams-platform in composer.json and commit your composer.lock. Expect the addon to lag behind platform releases.min/max on a range input is trivially bypassed. Add server-side rules on the field assignment or in the form definition ('rules' => ['integer', 'between:0,10']); don't rely on the widget."0", "10" — cast with (int) / (float) before comparing or doing math, and be careful with step when it's 0.1 (float drift on decimals).null or 0 depending on the view's default handling. Decide early and normalize in an accessor/mutator or a saving hook to avoid 0 masquerading as "not set".step => 0.1, make sure the underlying column is decimal/float, not integer, or you'll silently truncate.anomaly.field_type.slider::input). If the widget renders unstyled, run php artisan addon:publish and check that the associated JS/CSS is registered on the field type — a missing asset is the usual cause.$inputView in a subclass, or use view:clear after editing the Twig file. If nothing renders, confirm the addon was discovered (php artisan addon:list) — composer type: streams-addon is what triggers registration.SliderFieldType, override getInputView() / getConfig(), and register your subclass as its own addon rather than editing vendor files. Never patch the package in vendor/.How can I help you explore Laravel packages today?