Disabling file upload field in form

View: New views
2 Messages — Rating Filter:   Alert me  

Disabling file upload field in form

by Zoltan Lippai-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a form, where I need to disable some items (the user can't  
modify it, but he can see the fields values)
When the user submits the form, before validating it, I set the  
initial values for the disabled fields, so this way I can be sure, that
a) The user can't modify any of the disabled fields values
b) The fields get their values (if a field is disabled, then zend_form  
won't see its value)

This way everything was fine, until I needed a file upload field. When  
it is disabled, I get the following error during form validation:

Fatal error: Uncaught exception 'Zend_File_Transfer_Exception' with  
message '"newFile" not found by file transfer adapter' in /jail/web/
projekter.lativus.com/Zend/File/Transfer/Adapter/Abstract.php:1254  
Stack trace:
#0 /jail/web/projekter.lativus.com/Zend/File/Transfer/Adapter/
Abstract.php(572): Zend_File_Transfer_Adapter_Abstract-
 >_getFiles('newFile')
#1 /jail/web/projekter.lativus.com/Zend/Form/Element/File.php(435):  
Zend_File_Transfer_Adapter_Abstract->isValid('newFile')
#2 /jail/web/projekter.lativus.com/Zend/Form.php(1985):  
Zend_Form_Element_File->isValid(NULL, Array)
#3 /jail/web/projekter.lativus.com/application/default/controllers/
TaskController.php(311): Zend_Form->isValid(Array)
#4 /jail/web/projekter.lativus.com/Zend/Controller/Action.php(503):  
TaskController->editAction()
#5 /jail/web/projekter.lativus.com/Zend/Controller/Dispatcher/
Standard.php(285): Zend_Controller_Action->dispatch('editAction')
#6 /jail/web/projekter.lativus.com/Zend/Controller/Front.php(934):  
Zend_Controller_Dispatcher_Standard->dispatch(O in /jail/web/
projekter.lativus.com/Zend/File/Transfer/Adapter/Abstract.php on line  
1254

I suppose the file upload fields value also doesn't get submitted, but  
I don't think setting some value for it before validation will work in  
this case.

Do you have any suggestions about dealing with this problem?

Thanks,
Zoltan

Parent Message unknown Re: Disabling file upload field in form

by Mike Willbanks-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Zoltan,


You can solve this by using javascript to enable the field on submit.  Essentially this is not code based for the framework itself but rather it does not get sent from the browser when the field is disabled. 


Regards,


Mike


----- Original Message -----

From: Zoltan Lippai

Sent: 06/28/09 01:11 pm

To: fw-core@...

Subject: [fw-core] Disabling file upload field in form

 

Hi,

I have a form, where I need to disable some items (the user can't
modify it, but he can see the fields values)
When the user submits the form, before validating it, I set the
initial values for the disabled fields, so this way I can be sure, that
a) The user can't modify any of the disabled fields values
b) The fields get their values (if a field is disabled, then zend_form
won't see its value)

This way everything was fine, until I needed a file upload field. When
it is disabled, I get the following error during form validation:

Fatal error: Uncaught exception 'Zend_File_Transfer_Exception' with
message '"newFile" not found by file transfer adapter' in /jail/web/
projekter.lativus.com/Zend/File/Transfer/Adapter/Abstract.php:1254
Stack trace:
#0 /jail/web/projekter.lativus.com/Zend/File/Transfer/Adapter/
Abstract.php(572): Zend_File_Transfer_Adapter_Abstract-
>_getFiles('newFile')
#1 /jail/web/projekter.lativus.com/Zend/Form/Element/File.php(435):
Zend_File_Transfer_Adapter_Abstract->isValid('newFile')
#2 /jail/web/projekter.lativus.com/Zend/Form.php(1985):
Zend_Form_Element_File->isValid(NULL, Array)
#3 /jail/web/projekter.lativus.com/application/default/controllers/
TaskController.php(311): Zend_Form->isValid(Array)
#4 /jail/web/projekter.lativus.com/Zend/Controller/Action.php(503):
TaskController->editAction()
#5 /jail/web/projekter.lativus.com/Zend/Controller/Dispatcher/
Standard.php(285): Zend_Controller_Action->dispatch('editAction')
#6 /jail/web/projekter.lativus.com/Zend/Controller/Front.php(934):
Zend_Controller_Dispatcher_Standard->dispatch(O in /jail/web/
projekter.lativus.com/Zend/File/Transfer/Adapter/Abstract.php on line
1254

I suppose the file upload fields value also doesn't get submitted, but
I don't think setting some value for it before validation will work in
this case.

Do you have any suggestions about dealing with this problem?

Thanks,
Zoltan