Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to extend a model with more data
  • Hi,

    I would like to extend my Models data with all these data as XML also.

    So, actually I have:

                    $animal = Model_Animal::forge(array(
                        'name' => Input::post('name'),
                        'age' => Input::post('age'),
                    ));

    I get this data and change them to XML structure:

                    $xml = Format::forge($animal)->to_xml();

    So far so good, but now I want to extend the data from the Model_Animal with the new value rom $xml. How can I do that?

    I tried the following:

    1) Read out the data array:
                    $animal_array = $animal->to_array();
    2) Store all again together:
                    $animal = Model_Animal::forge()->set(array(
                        $animal_array,
                        'xml' => $xml,
                    ));

    But with no luck, _data is always empty after this step.

    Is there a way for me to do that?

    Thanks
    Kay
  • Oh, I found it :-)

                    $animal = Model_Animal::forge(array(
                        'name' => Input::post('name'),
                        'age' => Input::post('age'),
                    ));

                    // Extending Model with XML-Data
                    $animal = Model_Animal::forge($animal->to_array())->set(array(
                        'xml' => Format::forge($animal)->to_xml(),
                    ));

Howdy, Stranger!

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

In this Discussion