burnbright/silverstripe-componenteditor 问题修复 & 功能扩展

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

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

burnbright/silverstripe-componenteditor

Composer 安装命令:

composer require burnbright/silverstripe-componenteditor

包简介

Front-end component (DataObject) create/edit/delete control.

README 文档

README

A light-weight control for editing a single object, using it's getFrontEndFields. Useful for one-to-one (has_one, belongs_to) relationships.

A new object will be created on first save. Subsequently the form will be populated with the object data, and saved back to that object.

Usage

Update your DataObject as follows:

  • Implement/extend the getFrontEndFields method to control form fields.
  • Implement/extend the canCreate, canEdit, and canDelete functions to control access. see docs.

Add the EditComponentForm inside your controller class:

<?php
    public function Form() {
        //returns an empty object, if not aready present
        $testimonial = $this->owner->getMember()->Testimonial();
        return new EditComponentForm($this->owner, "Form", $testimonial);
    }
?>

Troubleshooting / future work

Make sure you implement the canCreate and canEdit and canDelete functions on your dataobject.

Currently works best if your object (eg Testimonial) contains the has_one relationship, if you are wanting to join to the parent (eg Member). This is because the EditComponentForm only saves the object you are working on, rather than the parent. Swap your has_one, with your belongs_to to resolve saving issues. Alternatively, save and link the new object before passing to the form (could end up creating a lot of empty objects). There is potential for this module to be upgraded to handle has_one relationships, perhaps by introducing a callback, or requiring that parent object be passed in.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-10-28