Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Tabular Forms
  • First of all, I think the code example in http://fuelphp.com/docs/classes/fieldset/fieldset.html#/one_to_many_forms is wrong. For example, there is no $data variable set in the second example. Where does it come from?

    I tried to make a tabular form working. 
    • A Model_Recipe Class has a $_has_many relationship call 'ingredients' with the Model_Ingredients class
    • In the controller, there is an item $item which is an existing Model_Recipe Object which has already one ingredient ($item->ingredients[]) set
    • I have now a $fieldset which has the $item set as model and a "set_tabular_form" set on the relationship.

    Before fieldset validation, the item relationship shows me:

    $item->ingredients = array( Model_Ingredient );

    After I run the validation(  $fieldset->validation()->run() ) there is a problem:

    $item->ingredients = array( array(...formdata....) );

    Now the $item->save() doesn't work anymore, since $item->ingredients isn't a array of Model_Ingredients, but an array of form data.


    And I don't understand how this can work ever. There is no primery key in the tabular form set (since primary keys are ignored by the fieldset class), so how can the model know, which row we want to update?
  • I will check the example. I am sure it works though, most of our applications use it on a daily basis.

    Here's an example of a working edit action for a simple invoice->invoice lines page:
    http://bin.fuelphp.com/snippet/view/AF

    The example doesn't talk about "ingredients", nor does it assign any array data to something that should contain models. So I think there's something wrong with your implementation.

Howdy, Stranger!

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

In this Discussion