2017 © Pedro Peláez
 

silverstripe-module silverstripe-customizableinputfield

SilverStripe form field for customizable input formats

image

nblum/silverstripe-customizableinputfield

SilverStripe form field for customizable input formats

  • Sunday, September 18, 2016
  • by nblum
  • Repository
  • 1 Watchers
  • 3 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

silverstripe-customizableinputfield


This package is deprecated. There will be no features or bug fixes in future., (*1)


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:, (*2)

_________ @example.com, (*3)


//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:, (*4)

+49 (0) ___ / _________, (*5)


//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>

The Versions

18/09 2016

dev-master

9999999-dev

SilverStripe form field for customizable input formats

  Sources   Download

MIT

The Requires

 

email silverstripe input postfix phone number prefix customizable