Skip to content
Autopopulate field descriptions to form fields
PHP
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
code
.editorconfig
.scrutinizer.yml
README.md
_config.php
composer.json

README.md

silverstripe-description

Takes form field descriptions through $db_descriptions and shows them in the edit form.

Usage

  1. Install using composer composer require "svandragt/silverstripe-description:*"
  2. 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

Example screenshot

  1. Unsaved message provided through ManyMessageDataExtension
  2. Styling for required formfields provided through RequiredFieldsCmsDataExtension
  3. Field descriptions automatically linked through DescriptionDataExtension
Something went wrong with that request. Please try again.