sunnysideup/hasoneedit 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sunnysideup/hasoneedit

Composer 安装命令:

composer require sunnysideup/hasoneedit

包简介

Allows editing the fields of a has_one object directly in the CMS

README 文档

README

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

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

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

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 FormFields for that object. Those FormFields 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

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.

sunnysideup/hasoneedit 适用场景与选型建议

sunnysideup/hasoneedit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「silverstripe」 「has_one」 「form fields」 「Silverstripe CMS」 「hasOne」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sunnysideup/hasoneedit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sunnysideup/hasoneedit 我们能提供哪些服务?
定制开发 / 二次开发

基于 sunnysideup/hasoneedit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 56
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: WTFPL
  • 更新时间: 2023-10-18