Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Loading data into form : BootstrapForm::loadDataFrom()

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

Page: 1
Go to End
Author Topic: 297 Views
  • Optic Blaze
    Avatar
    Community Member
    150 Posts

    Loading data into form : BootstrapForm::loadDataFrom() Link to this post

    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

  • Optic Blaze
    Avatar
    Community Member
    150 Posts

    Re: Loading data into form : BootstrapForm::loadDataFrom() Link to this post

    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));
    }

    297 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.