PHPackages                             sunnysideup/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. sunnysideup/hasoneedit

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

sunnysideup/hasoneedit
======================

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

3.0.2(2y ago)042WTFPLPHP

Since Aug 3Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (13)Used By (0)

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 `Sunnysideup\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

41

—

FairBetter than 89% of packages

Maintenance61

Regular maintenance activity

Popularity9

Limited adoption so far

Community13

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

Recently: every ~643 days

Total

11

Last Release

39d ago

Major Versions

1.0.7 → 2.0.02018-07-16

1.1.0 → 3.x-dev2019-03-14

3.0.2 → 5.x-dev2026-03-31

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/167154?v=4)[Sunny Side Up](/maintainers/sunnysideup)[@sunnysideup](https://github.com/sunnysideup)

---

Top Contributors

[![sunnysideup](https://avatars.githubusercontent.com/u/167154?v=4)](https://github.com/sunnysideup "sunnysideup (17 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

silverstripecmsSilverstripe-CMShas\_oneform-fieldshasOne

### Embed Badge

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

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

###  Alternatives

[stevie-mayhew/hasoneedit

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

21225.4k11](/packages/stevie-mayhew-hasoneedit)[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)
