PHPackages                             stevie-mayhew/hasoneedit - 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. [Admin Panels](/categories/admin)
4. /
5. stevie-mayhew/hasoneedit

ActiveSilverstripe-vendormodule[Admin Panels](/categories/admin)

stevie-mayhew/hasoneedit
========================

Allows editing the fields of a has\_one object directly in the CMS

2.3.0(2y ago)21225.4k↓16%15[3 issues](https://github.com/stevie-mayhew/hasoneedit/issues)11WTFPLPHP

Since Aug 3Pushed 2y ago5 watchersCompare

[ Source](https://github.com/stevie-mayhew/hasoneedit)[ Packagist](https://packagist.org/packages/stevie-mayhew/hasoneedit)[ RSS](/packages/stevie-mayhew-hasoneedit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (12)Used By (11)

Has One Edit
============

[](#has-one-edit)

This module allows you to directly edit the fields of a related `has_one` object directly, without having to mess around with `GridField` or links to `ModelAdmin`. If the related `has_one` doesn't exist yet, then this module also creates the object and sets up the relation for you on first write.

This module has been tested editing a `has_one` in both a `GridFieldDetailForm` and on a generic `Page` in `CMSMain`.

Requirements
------------

[](#requirements)

SilverStripe 4.x.

Basic testing has been carried out on 4.0.x-dev. Extensive testing may be required as SS4 becomes more solid.

Usage
-----

[](#usage)

To use this module, simply add a field to the CMS fields for your object in your `getCMSFields()` method. The name of the field should be `HasOneName-_1_-FieldName`.

For example, say you have a `has_one` called `Show` and that `has_one` has a field called `Title` you want to edit. You'd add the field `TextField::create('Show-_1_-Title', 'Show Title')`.

If you do not require that the outputted name of the field matches the value you supply, you can also use a colon as a separator instead of `-_1_-`.

### Generating fields with the `ProvidesHasOneInlineFields` trait

[](#generating-fields-with-the-provideshasoneinlinefields-trait)

If you simply want to display all the CMS fields for a related object, you can add the `ProvidesHasOneInlineFields` trait to the object. This adds a method which calls `getCMSFields()`on your `DataObject` and return the `FormField`s for that object. Those `FormField`s will be converted for use with this module by adding the relation name and separator to their name.

In the owning object, where you want to display the fields, call `HasOneEdit::getInlineFields($this, 'my_has_one_name', ['db'])`. This will return the `db` subset of fields for adding to the CMS - e.g. you can display the related object's fields in their own tab by calling `$fields->addFieldsToTab('Root.RelatedObject', HasOneEdit::getInlineFields($this, 'Relation', ['db']))`.

This has the advantage of running the entire `getCMSFields()` call tree (e.g. `updateCMSFields` for any functionality provided via extension) etc. without having to repeat logic in a lot of places.

You can also implement a method `public function provideHasOneInlineFields($relationName)` returning `FieldList|FormField[]` to provide a custom interface different to `getCMSFields()` (e.g. just a small subset of fields). In this case, all the field names should be in the form `$relationName . HasOneEdit::FIELD_SEPARATOR . $dataObjectFieldName`. This method will be called by `HasOneEdit::getInlineFields` even if your class does not use the `ProvidesHasOneInlineFields` trait.

### Using with your own form

[](#using-with-your-own-form)

To add support to your own forms, you need to add the `SGN\HasOneEdit\UpdateFormExtension` extension to your controller and call `$this->extend('updateEditForm', $form)` before returning the form to the template. Without this, the fields will not get populated with the values from the `has_one` though saving will work.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~310 days

Recently: every ~447 days

Total

11

Last Release

832d ago

Major Versions

1.0.7 → 2.0.02018-07-16

2.0.0 → 3.x-dev2019-03-14

1.2.0 → 2.1.02023-05-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/a499234983660ff4b31982de5e17e147544b717227fc4f7245070462fd03cbca?d=identicon)[stevie-mayhew](/maintainers/stevie-mayhew)

---

Top Contributors

[![sunnysideup](https://avatars.githubusercontent.com/u/167154?v=4)](https://github.com/sunnysideup "sunnysideup (16 commits)")[![stevie-mayhew](https://avatars.githubusercontent.com/u/1953220?v=4)](https://github.com/stevie-mayhew "stevie-mayhew (11 commits)")[![hchokshi](https://avatars.githubusercontent.com/u/10136407?v=4)](https://github.com/hchokshi "hchokshi (8 commits)")[![obj63mc](https://avatars.githubusercontent.com/u/443120?v=4)](https://github.com/obj63mc "obj63mc (2 commits)")[![xini](https://avatars.githubusercontent.com/u/1152403?v=4)](https://github.com/xini "xini (1 commits)")[![michalkleiner](https://avatars.githubusercontent.com/u/233342?v=4)](https://github.com/michalkleiner "michalkleiner (1 commits)")[![wernerkrauss](https://avatars.githubusercontent.com/u/1043925?v=4)](https://github.com/wernerkrauss "wernerkrauss (1 commits)")[![dizzystuff](https://avatars.githubusercontent.com/u/576903?v=4)](https://github.com/dizzystuff "dizzystuff (1 commits)")

---

Tags

silverstripecmshas\_one

### Embed Badge

![Health badge](/badges/stevie-mayhew-hasoneedit/health.svg)

```
[![Health](https://phpackages.com/badges/stevie-mayhew-hasoneedit/health.svg)](https://phpackages.com/packages/stevie-mayhew-hasoneedit)
```

###  Alternatives

[colymba/gridfield-bulk-editing-tools

Silverstripe CMS GridField component to upload images/files and edit records in bulk

94677.2k39](/packages/colymba-gridfield-bulk-editing-tools)[silverstripe/admin

SilverStripe admin interface

262.6M325](/packages/silverstripe-admin)[unclecheese/dashboard

Adds a dashboard to the SilverStripe CMS

4742.3k1](/packages/unclecheese-dashboard)[praxisnetau/silverstripe-moderno-admin

A SilverStripe module to give the CMS a more modern, flat appearance.

224.4k](/packages/praxisnetau-silverstripe-moderno-admin)

PHPackages © 2026

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