Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Model with Image and propreties
  • Hello,

    I'm trying to figure out how the edit_action is working.

    I have a model: Model_Car where it has an image as part of the model with the properties:
    image_name, type, size, extension.

    I'm able to save the image, but the model save fails since the properties such as: type, size and extension are not sent with the Post.

    I see in the edit aciton:

            $car = Model_Car::find($id);
            $val = Model_Car::validate('edit');

            if ($val->run())
            {
                $car->name = Input::post('name');
          //      $car->real_file_name = Input::post('file_type');
          //      $car->file_type = Input::post('file_type');
    ....
            }
             else
            {
                if (Input::method() == 'POST')
                {
                                 if (Upload::is_valid())
                                 {
                                     Upload::save();
                                 }
                                
                                 // get the list of successfully uploaded files
                                 foreach(Upload::get_files() as $file)
                                 {
                                       $car->name = $val->validated('name');
                                       $car->real_file_name = $file['name'];
                                       $car->file_type= $file['mimetype'];
                                 }
                                 Session::set_flash('error', $val->error());
                  }
            }


    So I tried to comment out the main validation section, but it still throws back the errors even though the file saves correctly (which I would like to not... both should fail and rollback if one of the processes fails.)

    I would also like this to be able to handle multiple images saving a new row for each image uploaded using the same content entered into the form.

    So any ideas on why or how I should setup the action to not throw back the errors on fields I want to set from the uploaded image?

    Are there transient properties?

    Thanks.

Howdy, Stranger!

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