svandragt / silverstripe-description
Takes form field descriptions through $db_descriptions and shows them in the edit form.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Type:silverstripe-module
Requires
This package is not auto-updated.
Last update: 2020-02-03 04:14:07 UTC
README
Takes form field descriptions through $db_descriptions and shows them in the edit form.
Usage
- Install using composer
composer require "svandragt/silverstripe-description:*"
- Attach it to your data objects / page types through the configuration system as follows:
Object::add_extension("DataObject","DescriptionDataExtension");
DIY Demo:
Course.php:
<?php
class Course extends DataObject {
public static $db = array(
'Title' => 'Varchar(500)',
'IPPCode' => 'Varchar(20)',
);
public static $db_descriptions = array(
'IPPCode' => 'Lookup to existing IPP Code if available',
);
}
CourseModelAdmin.php:
<?php
class CourseModelAdmin extends ModelAdmin {
public static $managed_models = array(
'Course',
);
static $url_segment = 'courses'; // Linked as /admin/products/
static $menu_title = 'Course Admin';
}
Do a /dev/build and create a new course in the CMS. You will see the IPPCode field has a description below it.
Screenshot
- Unsaved message provided through ManyMessageDataExtension
- Styling for required formfields provided through RequiredFieldsCmsDataExtension
- Field descriptions automatically linked through DescriptionDataExtension