Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ checks:
argument_type_checks: true

filter:
paths: [code/*, tests/*]
paths: [src/*, tests/*]
105 changes: 61 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
silverstripe-bootstrap-forms
============================

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

## Basic Usage
Just use the "BootstrapForm" subclass instead of Form.
Expand All @@ -25,75 +25,92 @@ $form = BootstrapForm::create(
### Bonus form fields
* SimpleHtmlEditorField
* ChosenDropdownField
* ChosenListboxField
* Textarea with maxlength

### The "Kitchen Sink" example
The following example showcases all of the options available on BootstrapForm and the BootstrapFormField extensions.

```php
<?php
public function FancyForm() {
public function FancyForm()
{
return BootstrapForm::create(
$this,
Controller::curr(),
"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"))
TextField::create("ATextField", "A text field with prepended and appended text")
->prependText("$")
->appendText(".00"),
CheckboxSetField::create("InlineCheckboxes", "Inline Checkboxes")
->setSource(DataList::create(SiteTree::class))
->setInline(true)
->setColumns([
'xs' => 12,
'sm' => 12,
'md' => 6,
'lg' => 3
]),
CheckboxSetField::create("Checkboxes", "Checkboxes")
->setSource(DataList::create(SiteTree::class))
->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'))
OptionsetField::create("InlineRadios", "Inline Radios")
->setSource(DataList::create(SiteTree::class)->map('ID', 'Title'))
->setInline(true)
->setColumns([
'xs' => 12,
'sm' => 12,
'md' => 6,
'lg' => 3
]),

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

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

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

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




->setSource(SiteTree::get()->map()),
ChosenListboxField::create("ListboxSelect", "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...")
FormAction::create("yes", "YES!")
->setStyle("success")
->setSpan(6)
->setSize('lg'),
FormAction::create("no", "NO!")
->setStyle("danger")
->setSpan(7)
->setSize('sm'),
FormAction::create("maybe", "Maybe...")
->setStyle("info"),
FormAction::create("sure","Sure!")
->setStyle("primary"),
FormAction::create("uhoh","Uh-oh")
FormAction::create("sure", "Sure!")
->setStyle("primary")
->setSpan(2),
FormAction::create("uhoh", "Uh-oh")
->setStyle("warning")
)
)
->addWell()
->setLayout("horizontal");
}

->setLayout("horizontal");
}



```
```
2 changes: 1 addition & 1 deletion _config.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

define('BOOTSTRAP_FORMS_DIR',basename(dirname(__FILE__)));
define('BOOTSTRAP_FORMS_DIR','vendor/unclecheese/bootstrap-forms/');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this defined anymore. Use module references in Requirements:: calls.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 034d9e8

55 changes: 31 additions & 24 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
---
name: BootstrapForm
---
BootstrapForm:
bootstrap_included: false
jquery_included: false
bootstrap_form_included: false
bootstrap_select_included: false
UncleCheese\BootstrapForms\BootstrapForm:
bootstrap_included: true
jquery_included: true
bootstrap_form_included: true
bootstrap_select_included: true
inline_fields:
- CheckboxField
- FormAction
FormField:
- SilverStripe\Forms\CheckboxField
- SilverStripe\Forms\FormAction
SilverStripe\Forms\FormField:
extensions:
- UncleCheese\BootstrapForms\BootstrapFormField
SilverStripe\Forms\DropdownField:
extensions:
- UncleCheese\BootstrapForms\BootstrapDropdownField
SilverStripe\Forms\TextField:
extensions:
- BootstrapFormField
TextField:
- UncleCheese\BootstrapForms\BootstrapTextField
SilverStripe\Forms\OptionsetField:
extensions:
- BootstrapTextField
OptionsetField:
- UncleCheese\BootstrapForms\BootstrapOptionsetField
SilverStripe\Forms\FormAction:
extensions:
- BootstrapOptionsetField
FormAction:
- UncleCheese\BootstrapForms\BootstrapFormAction
SilverStripe\Forms\TextareaField:
extensions:
- BootstrapFormAction
TextareaField:
- UncleCheese\BootstrapForms\BootstrapTextField
SilverStripe\Forms\FieldList:
extensions:
- BootstrapTextField
FieldList:
- UncleCheese\BootstrapForms\BootstrapFieldList
SilverStripe\Forms\CheckboxSetField:
extensions:
- BootstrapFieldList
Injector:
MemberLoginForm:
class: BootstrapMemberLoginForm
- UncleCheese\BootstrapForms\BootstrapCheckboxSetField
SilverStripe\Core\Injector\Injector:
SilverStripe\Security\MemberAuthenticator\MemberLoginForm:
class: UncleCheese\BootstrapForms\BootstrapMemberLoginForm
---
only:
moduleexists: userforms
---
UserDefinedForm_Controller:
SilverStripe\UserForms\Control\UserDefinedFormController:
extensions:
- BootstrapUserForm
- UncleCheese\BootstrapForms\BootstrapUserForm
28 changes: 0 additions & 28 deletions code/BootstrapDropdownField.php

This file was deleted.

47 changes: 0 additions & 47 deletions code/BootstrapFormAction.php

This file was deleted.

17 changes: 0 additions & 17 deletions code/BootstrapMemberLoginForm.php

This file was deleted.

Loading