If you look at the code in the behavior, you'll see that the messages
are generated in the setupUploadValidations() method, which is called
at the end of the setup() method.
So basically, after you've changed the settings, call
setupUploadValidations() again manually and they should be updated,
something like this:
$b =& $this->Post->Attachment->behaviors['ImageUpload'];
$b->settings['Attachment'] = am(
$b->settings['Attachment'],
array(
'allowedSize' => '1',
'allowedSizeUnits' => 'KB'
)
);
$b->setupUploadValidations($this->Post->Attachment);
On Nov 7, 1:01 pm, "R. Rajesh Jeba Anbiah"
<[EMAIL PROTECTED]> wrote:
> I'm looking to dynamically change the behavior's settings from
> controller. Background: I'm trying to change the "allowedSize" aka
> upload limit in Andy's UploadBehavior toolkit.
>
> I came up with this:
> $this->Post->Attachment->behaviors['ImageUpload']->settings['Attachment'] =
> am($this->Post->Attachment-
> >behaviors['ImageUpload']->settings['Attachment'], array(
>
> 'allowedSize' => '1',
> 'allowedSizeUnits' => 'KB',
> ));
>
> The current disadvantage of this method is that I couldn't find a way
> to change the validation error message (Still showing default "The
> file uploaded is too big, only files less than 8 MB permitted.")
>
> Just like to know if there is any better approach for this?
>
> --
> <?php echo 'Just another PHP saint'; ?>
> Email: rrjanbiah-at-Y!com Blog:http://rajeshanbiah.blogspot.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---