Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Issue with Form Helper array('type' => 'file')
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kro  
View profile  
 More options Feb 23 2012, 5:28 am
From: Kro <yenohamonin...@gmail.com>
Date: Thu, 23 Feb 2012 02:28:03 -0800 (PST)
Local: Thurs, Feb 23 2012 5:28 am
Subject: Issue with Form Helper array('type' => 'file')
I am saving a Rate record and an associated image using the Media
plugin (https://github.com/davidpersson/media). Everything works fine
when an image is added, when an image isn't added the Rate record gets
corrupted.

The array is as follows:

Array ( [Rate] => Array ( [enabled] => 0 [is_corporate] => 0
[special_offer] => 0 [list_no] => 0 [id_ref] => 43564566 [title] =>
rate7 [price_quote_as] => 0 [adult_supplement] => 0 [child_supplement]
=> 0 [supplement] => 0 [short_description] => rate7 [description] =>

rate7
[available] => Array ( [0] => 2 ) [minimum_stay] => 0 [maximum_stay]
=> 0 [valid_from] => 2012-02-24 [valid_to] => 2012-02-25 [file] =>
Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
[Room] => Array ( [Room] => Array ( [0] => 16 ) ) )

Note the 'file' array with the error 4.

Any help would be greatly appreciated.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeremyharris  
View profile  
 More options Feb 23 2012, 10:34 am
From: jeremyharris <funeralm...@gmail.com>
Date: Thu, 23 Feb 2012 07:34:13 -0800 (PST)
Local: Thurs, Feb 23 2012 10:34 am
Subject: Re: Issue with Form Helper array('type' => 'file')

What do you mean by corrupted? It should fail gracefully and stop the save
process if there's an error.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kro  
View profile  
 More options Feb 23 2012, 6:40 pm
From: Kro <yenohamonin...@gmail.com>
Date: Thu, 23 Feb 2012 15:40:11 -0800 (PST)
Local: Thurs, Feb 23 2012 6:40 pm
Subject: Re: Issue with Form Helper array('type' => 'file')
Thanks for taking the time to reply @jeremyharris. The record is still
getting written but the 'Rate' data is missing. The following is an
example of a saved record. As you can see the 'Rate' data is missing.

Array
(
    [Rate] => Array
        (
            [id] => 92
            [id_ref] =>
            [title] =>
            [short_description] =>
            [description] =>
            [price_quote_as] =>
            [adult_supplement] => 0.00
            [child_supplement] => 0.00
            [supplement] => 0.00
            [minimum_stay] => 0
            [maximum_stay] => 0
            [imagefile] =>
            [enabled] => 0
            [special_offer] => 0
            [list_no] => 0
            [availability] =>
            [valid_from] => 0000-00-00 00:00:00
            [valid_to] => 0000-00-00 00:00:00
            [is_corporate] => 0
            [created] => 0000-00-00 00:00:00
            [updated] => 0000-00-00 00:00:00
            [deleted] => 0
            [dirname] =>
            [basename] =>
        )

    [Room] => Array
        (
            [0] => Array
                (
                    [id] => 15
                    [title] => Deluxe Double Room
                    [description] => Situated in the new wing of....
                    [min_adults] => 2
                    [max_adults] => 2
                    [max_children] => 0
                    [no_of_rooms] => 0
                    [enabled] => 1
                    [list_no] => 2
                    [created] => 2011-09-04 21:37:08
                    [updated] => 2011-09-05 17:00:55
                    [deleted] => 0
                    [dirname] => img
                    [basename] => deluxe_bedroom_2.jpg
                    [RatesRoom] => Array
                        (
                            [id] => 1942
                            [rate_id] => 92
                            [room_id] => 15
                            [dirname] =>
                            [basename] =>
                        )

                )

        )

    [CorporateAccount] => Array
        (
        )

)

On Feb 23, 3:34 pm, jeremyharris <funeralm...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeremyharris  
View profile  
 More options Feb 23 2012, 9:19 pm
From: jeremyharris <funeralm...@gmail.com>
Date: Thu, 23 Feb 2012 18:19:40 -0800 (PST)
Local: Thurs, Feb 23 2012 9:19 pm
Subject: Re: Issue with Form Helper array('type' => 'file')

What behaviors are you using besides Transfer? Coupler tends to mess with
the data because it expects *just* the fields in the Media.Attachment
model. Try removing Coupler if it's attached (since you're not using it).

Also, unit tests are your friend. It would be much easier to try things and
debug using unit tests rather than not.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kro  
View profile  
 More options Feb 24 2012, 4:02 am
From: Kro <yenohamonin...@gmail.com>
Date: Fri, 24 Feb 2012 01:02:05 -0800 (PST)
Local: Fri, Feb 24 2012 4:02 am
Subject: Re: Issue with Form Helper array('type' => 'file')
Thanks for your reply. Okay, sounds like it could be related to the
Coupler then. I tried removing the Coupler and the 'Rate' data is then
saving correctly but the image is missing. I am using 'dirname' and
'basename' fields in the 'Rate' table rather than using a separate
Attachment table, does this mean I don't need the Coupler element?

On Feb 24, 2:19 am, jeremyharris <funeralm...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeremyharris  
View profile  
 More options Feb 24 2012, 12:48 pm
From: jeremyharris <funeralm...@gmail.com>
Date: Fri, 24 Feb 2012 09:48:32 -0800 (PST)
Local: Fri, Feb 24 2012 12:48 pm
Subject: Re: Issue with Form Helper array('type' => 'file')

Okay I think I misspoke. You do need the coupler. (Sorry lack of docs and
it's been a while since I had to configure.)

I'd stick some debug statements through all of the behaviors' beforeSave
calls to try and figure out what's happening. I'm suspicious that the rate
data is being removed in Coupler's beforeSave due to some issue with the
'file' key not being there or not being validated. This will hopefully give
you a better understanding of what's going on.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kro  
View profile  
 More options Feb 25 2012, 1:48 pm
From: Kro <yenohamonin...@gmail.com>
Date: Sat, 25 Feb 2012 10:48:59 -0800 (PST)
Local: Sat, Feb 25 2012 1:48 pm
Subject: Re: Issue with Form Helper array('type' => 'file')
Thank you so much, it's working now! You were spot on, it was the
Couplers beforesave that was unsetting the data. I have stopped it
doing that now and I can't see why that would cause any other issues.

The change I have made is as follows:
function beforeSave(&$Model) {
                if (!$Model->exists()) {
                        if (!isset($Model->data[$Model->alias]['file'])) {
        removed unset --->                   //unset($Model->data[$Model-

>alias]);

                                return true;
                        }
                } else {
                        if (isset($Model->data[$Model->alias]['delete'])
                        && $Model->data[$Model->alias]['delete'] !== '0') {
                                $Model->delete();
                                unset($Model->data[$Model->alias]);
                                return true;
                        }
                }

Thanks again...

On Feb 24, 5:48 pm, jeremyharris <funeralm...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeremyharris  
View profile  
 More options Feb 25 2012, 3:17 pm
From: jeremyharris <funeralm...@gmail.com>
Date: Sat, 25 Feb 2012 12:17:39 -0800 (PST)
Local: Sat, Feb 25 2012 3:17 pm
Subject: Re: Issue with Form Helper array('type' => 'file')

Awesome, glad you figured it out!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kro  
View profile  
 More options Feb 25 2012, 10:01 pm
From: Kro <yenohamonin...@gmail.com>
Date: Sat, 25 Feb 2012 19:01:56 -0800 (PST)
Local: Sat, Feb 25 2012 10:01 pm
Subject: Re: Issue with Form Helper array('type' => 'file')
Couldn't have done it without you...cheers...

On Feb 25, 8:17 pm, jeremyharris <funeralm...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »