anomaly/url-field_type
Anomaly URL Field Type adds a URL field type for Laravel Streams, letting you capture, validate, and display website links in control panels and forms with a simple, focused input field.
This addon registers a single field type, anomaly.field_type.url, for the PyroCMS/Streams platform. It is almost always pulled in transitively by pyrocms/pyrocms or anomaly/streams-platform, so a manual composer require anomaly/url-field_type is usually only needed on stripped-down installs.
Where to look first:
src/UrlFieldType.php — the field type class; this is where getInputView(), getRules(), and any presenter wiring live.src/UrlFieldTypePresenter.php — if present, this is what $entry->my_field returns. Check whether it adds helpers like link()/path() or just returns the raw string.resources/views/input.twig — the admin form markup (an <input type="url">).resources/config/config.php — any tweakable validation rules or defaults.resources/lang/en/addon.php — the name/description registered into the admin field type picker.First use case: add a "Website" URL to an existing stream. In your migration/seed (or via the Streams admin UI → Fields → Add Field), set the field type to url. In the admin form builder this appears as a plain text input with browser-level URL validation; on save it stores a string column.
Minimal migration-style assignment:
$stream->addField('website', [
'type' => 'anomaly.field_type.url',
'config' => [
'default_value' => 'https://example.com',
],
]);
Reading the value. The field is stored as a varchar/text column. Access it exactly like any other field:
{{ entry.website }}
If the field ships a presenter, $entry->website will be a UrlFieldTypePresenter in PHP, but when echoed in Twig it casts to the string. Guard against empty values — a URL field is frequently optional:
{% if entry.website %}
<a href="{{ entry.website }}" rel="noopener" target="_blank">{{ entry.website }}</a>
{% endif %}
Composing with other field types. Pair this field with a text field for a human-readable label (e.g. website_label) rather than trying to derive one. The URL field type deliberately does not model a link object.
Validation. The addon typically adds the url rule (and sometimes active_url). If you need to accept relative paths, protocol-less values, or internal routes, don't fight the field type — add a custom rule via the field's config or override getRules() in a subclassed field type:
protected $rules = ['nullable', 'string', 'max:255'];
Presenter extension. If you need ->domain() or ->favicon(), extend UrlFieldTypePresenter in your own addon and register it through the field type's $presenter binding, rather than editing vendor code.
Form rendering in custom modules. If you're hand-rolling a form outside the Streams form builder, render the field's input view directly:
{{ form.fields.website.input|raw }}
Twig-safe output. Since the value is a user-supplied URL, always let Twig autoescape. Do not use |raw on the URL itself; only use |raw on the rendered input HTML in admin contexts.
example.com, you will store example.com. Add a mutator or a saving hook on the entry if that matters to you.target="_blank", rel="noopener", or favicon behavior is your responsibility.'' rather than null for blank optional fields. {% if entry.website %} handles both, but entry.website is null does not. Prefer truthiness checks.url rule rejects protocol-relative (//cdn.example.com) and relative (/contact) values. This bites when people reuse the field type for internal paths — use a text field for those, or loosen the rules.VARCHAR(255) and someone pastes a signed URL, it truncates (or errors depending on MySQL mode). Use text for anything that may hold query strings.config.php is merged at the addon level, not per-field, unless you override values in the field definition's config array. Field-level config wins; keep that in mind when debugging why a rule "isn't applying."SELECT website FROM ...), then check whether a presenter is swallowing it. A common cause is a presenter method name matching the field name and returning null.Anomaly\UrlFieldType\UrlFieldTypeServiceProvider).UrlFieldType to change getRules()/getConfig(), overriding the presenter for helper methods, and publishing the input view to your own addon's resources/views to change the admin markup — in that order of preference.How can I help you explore Laravel packages today?