Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fieldset populate field values from Nested model?
  • Currently the Fieldset populate() method only populates values for a single Model. but if it has related Models it won't populate those fields .
    $form = \Fieldset::factory('report')->add_model('Pages\Model_Report')->populate($page, true);

    -- id
    -- user_id
    -- section
    -- title
    -- content Model_Report
    -- id
    -- page_id
    -- assigned_id
    -- report_link
    Model_Page::query()->where('id', $id)->where('section', 'report')->related('report')->get_one();

    Model_Page is related to Model_Report in one-to-one. The form has inputs for both tables, and right now only the field values for Model_Page only get populated. Right now I'm just doing:
    $form = \Fieldset::factory('report')->add_model('Pages\Model_Report')->populate($page, true)->populate($page->report, true);

    But i think there must be some other way of handling populating forms for related models.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!