Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Loading data into form : BootstrapForm::loadDataFrom()


Go to End


2 Posts   1553 Views

Avatar
Optic Blaze

Community Member, 190 Posts

8 October 2013 at 12:04pm

I am trying to load data into a form. I am using the bootstrap-forms module from Uncle Cheese. As i understand it i would normally call $form->loadDataFrom(Customer::get()->byID(4)) but the bootstrap module structures the form differently.

//CREATE CUSTOMER FORM
public function CustomerForm() {
return BootstrapForm::create(

$this,
"CustomerForm",
FieldList::create(
TextField::create("Name","Name")
TextField::create("Surname","Surname"),

FieldList::create(
FormAction::create("AddCustomer","Add customer")
->setStyle("success")
),
RequiredFields::create(array("Name","Surname","Tel1", "Address")),

/// I think the load data method should go here but i keep getting errors
BootstrapForm::loadDataFrom(Customer::get()->byID(4))

)
}

Any help will be appreciated

Avatar
Optic Blaze

Community Member, 190 Posts

11 October 2013 at 10:38am

GOT IT!!!!!

/CREATE CUSTOMER FORM
public function CustomerForm() {
return BootstrapForm::create(

$this,
"CustomerForm",
FieldList::create(
TextField::create("Name","Name")
TextField::create("Surname","Surname"),

FieldList::create(
FormAction::create("AddCustomer","Add customer")
->setStyle("success")
),
RequiredFields::create(array("Name","Surname","Tel1", "Address")),
)
->loadDataFrom(Customer::get()->byID(4));
}