Git Product home page Git Product logo

silverstripe-bootstrap-forms's Introduction

silverstripe-bootstrap-forms

Allows the creation of forms compatible with the Twitter Bootstrap CSS framework in SilverStripe 3.

Basic Usage

Just use the "BootstrapForm" subclass instead of Form.

<?php

$form = BootstrapForm::create(
  $this,
  "MyBootstrapForm",
  FieldList::create(
    TextField::create("Name")
      ->addHelpText('Enter some text above')
  ),
  FieldList::create(
    FormAction::create("doStuff","Click this!")
      ->setStyle("success")
  )
);

Bonus form fields

  • SimpleHtmlEditorField
  • ChosenDropdownField
  • Textarea with maxlength

The "Kitchen Sink" example

The following example showcases all of the options available on BootstrapForm and the BootstrapFormField extensions.

<?php
public function FancyForm() {
    return BootstrapForm::create(
        $this,
        "FancyForm",
        FieldList::create(
            TextField::create("ATextField","A text field with prepended and appended text")
            	->prependText("$")
            	->appendText(".00"),
            CheckboxSetField::create("InlineCheckboxes","Inline Checkboxes")
                ->setSource(DataList::create("SiteTree"))
                ->setInline(true),
            CheckboxSetField::create("Checkboxes","Checkboxes")
                ->setSource(DataList::create("SiteTree"))                   
                ->addHelpText("Check some of these."),
            OptionsetField::create("InlineRadios","Inline Radios")
                ->setSource(DataList::create("SiteTree")->map('ID','Title'))
                ->setInline(true),                  

            OptionsetField::create("Radios","Radios")
                ->setSource(DataList::create("SiteTree")->map('ID','Title'))                    
                ->addHelpText("Check one of these."),

            DropdownField::create("Dropdown","Dropdown")
                ->setSource(DataList::create("SiteTree")->map('ID','Title'))
                ->addInlineHelpText("<-- look at that!"),
            TextareaField::create("Textarea","Textarea"),
            TextField::create("BigText","Massive text field")
                ->setSize("xxlarge"),

            TextField::create("SmallText","Tiny text field")
                ->setSize("mini"),

            SimpleHtmlEditorField::create("HTML", "HTML Editor")
            	->setButtons("bold,italic"),
            ChosenDropdownField::create("FancyDropdown", "Fancy dropdown")
            	->setSource(SiteTree::get()->map()),
            TextareaField::create("MaxLengthTextarea","Textarea with a maxlength")
            	->setAttribute('maxlength',150)




        ),
        FieldList::create(
            FormAction::create("yes","YES!")
                ->setStyle("success"),
            FormAction::create("no","NO!")
                ->setStyle("danger"),
            FormAction::create("maybe","Maybe...")
                ->setStyle("info"),
            FormAction::create("sure","Sure!")
                ->setStyle("primary"),
            FormAction::create("uhoh","Uh-oh")
                ->setStyle("warning")
        )
    )
        ->addWell()
        ->setLayout("horizontal");	
    }
	
}

silverstripe-bootstrap-forms's People

Contributors

jrast avatar icecaster avatar unclecheese avatar zauberfisch avatar manuelteuber avatar

Watchers

James Cloos avatar Michael van Schaik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.