- Thanks for that i have been working through the SS-Bit tutorials and found it useful.
- Found a really cool module by Uncle Cheese called Bootstrap-forms that uses the twitter bootstrap framework:
http://www.leftandmain.com/silverstripe-screencasts/2012/07/03/bootstrap-forms-for-silverstripe-3/
- The way you set up the forms are brilliant and i find it easier to apply methods to objects using this style.
- One of the cool features is the called FancyDropdown that adds a AJAX style search functionality to a drop down field. I tested it with a list of 1600 postal codes and areas and it works <b>REALLY WELL </b>
The only thing i am struggling with at the moment is populating the form with existing records so that i can update records. I.e if i want to update customer number 3 i want to be able to call something like this in the browser....mysite/customer/edit/3
Which should bring up the form populated with the customer's details.
I know the old way of doing that was something like $form->loadDataFrom($this->editform());
This is what the code looks now:
----------------------------------------------------------------------
//CREATE CUSTOMER FORM
public function CustomerForm() {
return BootstrapForm::create(
$this,
"CustomerForm",
FieldList::create(
TextField::create("Name","Name")
->addExtraClass("required"),
TextField::create("Surname","Surname"),
ChosenDropdownField::create("PostalCodesID", "Postal Addres") ///Fancy Drop down field
->setSource(PostalCode::get()->map('ID','Suburb'))
->setEmptyString('--Please Select--'))
),
BootstrapForm::loadDataFrom($this->editform())
)
}
// ADD CUSTOMER TO DATABASE
public static function AddCustomer($data, $form) {
$submission = new Customer();
$form->saveInto($submission);
$submission->write();
Controller::curr()->redirectBack();
}
}
----------------------------------------------------------------------------
- The module has excellent validation features
- You can do a horizontal layout with checkboxes and radio buttons
- Prepend and apend text to fields
- Customize different buttons to look different...eg submit button is green, delete button is red
And all of this comes out the box!