Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pivot table problems
  • Hi, This is my first time to try pivot table on a $_many_many relationship here at FuelPHP. Having some problems. I hope you can help. Here's the situation: I have a form - Communication cards. Each communication card will have multiple Requests that the user will check. Here's the code for the multiple check boxes http://pastecode.com/mR Here's my model for Comcards http://pastecode.com/mS
    Here's my model for Requests http://pastecode.com/mT Here's my pivot table comcards_requests http://pastecode.com/mU I can't figure out how to save the selected items to comcards_requests without having an error. I tried several approaches but still wouldn't work. Need help. Thanks!
  • Could you give the actual code you used and the error as well?
  • Hi Jelmer http://pastecode.com/mV This is mostly generated via the scaffold. But line 16 is the one I was trying. I tried other methods (like doing that after the save(), etc, but would work. Here's the screenshot of the error... https://skitch.com/e-arnoldgamboa/g491u/fuel-php-framework Thanks.
  • The following line is the cullprit: $comcard->requests[] = Input::post('requests'); You can't add numbers, you have to add object instances:
    foreach(Input::post('requests', array()) as $req)
    {
        $comcard->requests[] = Model_Request::find($req);
    }
    
  • Jelmer, you're the best. :D Thanks! (I was doing it the Kohana way. I guess I need to unlearn some stuff :D)

Howdy, Stranger!

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

In this Discussion