Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM, CRUD and inserting records with many to many relations
  • Being completely new to FuelPHP I have a few questions...
    I started creating a simple blog application using Oils scaffolding functionality. After that I've set up all relations between my tables following the ORM docs (tables are called 'posts', 'categories' and 'categories_posts' ). Everthing works perfectly and as espected so far, e.g. selecting data with relations (posts and their associated categories).
    But now I'm stuck with creating new posts using the form generated by Oil. I've modified it and added a checkbox for every category stored in the DB. Submitting the form will insert a record into the 'posts' table but not into the 'categories_posts' table.
    Is this a matter of naming the checkboxes correctly? Or do I need to write a model for the 'categories_posts' table? Or am I on a complete wrong path? Thanks in advance for pointing me into the right direction,
    Greg
  • Your code will not do something magical. In the end it's still PHP, with a form containing variables that are posted, that need to be validated, processed, passed to a model, and saved.
  • Ok, thanks. Using an ORM for the first time, stuff like
    $data['posts'] = Model_Post::find('all', array('related' => array('categories')));
    
    working out of the box is already magical to me... so I thought it may be working as well for data creation.

Howdy, Stranger!

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

In this Discussion