Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

nblum/silverstripe-customizableinputfield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silverstripe-customizableinputfield


This package is deprecated. There will be no features or bug fixes in future.


Requirements

  • Silverstripe 3.*

Installation

Composer

  • composer require "nblum/silverstripe-customizableinputfield"

Manual

  • Download and copy module in SilverStripe root directory

Usage

Adding fields on a page

    private static $db = array(
        'Field' => 'CustomizableInputField'
    );

Example for mail address with pre defined domain:

_________ @example.com

    
    //creates a new fieldset
    $field = new CustomizableInputFieldSet('Field', 'Email address');
    
    //creates a new part
    $part1 = new CustomizableInputFieldPart();
    $part1->setAfter('@example.com');
    $part1->setMaxLength(15);
    $field->addPart($part1);
    
    //adds the customized fieldset to the tab
    $fields->addFieldToTab('Root.Main', $field, 'Content');
            

Example for (german) mobile phone numbers:

+49 (0) ___ / _________

    
    //creates a new fieldset
    $field = new CustomizableInputFieldSet('Field', 'Mobile Phone');

    //creates a new part
    $part1 = new CustomizableInputFieldPart();
    //the first param will be visible in admin form, the second in the template
    $part1->setBefore('+49', '+49 (0)');
    $part1->setAfter('/');
    $part1->setMaxLength(3);
    $field->addPart($part1);

    //creates a second part
    $part2 = new CustomizableInputFieldPart();
    $part2->setMaxLength(9);
    $field->addPart($part2);

    //adds the customized fieldset to the tab
    $fields->addFieldToTab('Root.Main', $field, 'Content');
            

Render values on a template

    <!-- show the concatenated string for simple output -->
    <p>$Field1.Strval</p>
    
    <!-- loop over all parts of fieldset, for more individual output -->
    <p>
        <% loop $Field1.Parts %>
            <span>$Before $Value $After</span>
        <% end_loop %>
    </p>
    

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published