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.

Data Model Questions /

Loading data into form : BootstrapForm::loadDataFrom()


Reply


2 Posts   435 Views

Avatar
Optic Blaze

Community Member, 163 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, 163 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));
}