Jump to content

Frontend form single image field save problem


gebeer
 Share

Recommended Posts

Hello,

I am building a frontend form following Soma's great example on a PW 2.7.2 stable install. 

The pages that I edit with the form already exist.

 

My form includes a single image field, CKEditor fields and some normal text fields.

The form renders fine, all CSS and JS is in place. I can even use the pwImage plugin on the CKEditor field and it loads the image from that page.

When there already is an image present in the image field and I submit the form, I get this error:

Fatal error: Exception: Method Pageimage::path does not exist or is not callable in this context (in /var/www/utgpwnew/wire/core/Wire.php line 358) #0 [internal function]: Wire->___callUnknown('path', Array) #1 /var/www/utgpwnew/wire/core/Wire.php(398): call_user_func_array(Array, Array) #2 /var/www/utgpwnew/wire/core/Wire.php(333): Wire->runHooks('callUnknown', Array) #3 /var/www/utgpwnew/wire/core/Wire.php(337): Wire->__call('callUnknown', Array) #4 /var/www/utgpwnew/wire/core/Wire.php(337): Pageimage->callUnknown('path', Array) #5 /var/www/utgpwnew/wire/modules/Fieldtype/FieldtypeFile.module(119): Wire->__call('path', Array) #6 /var/www/utgpwnew/wire/modules/Fieldtype/FieldtypeFile.module(119): Pageimage->path() #7 /var/www/utgpwnew/wire/core/Wire.php(459): FieldtypeFile->hookProcessInput(Object(HookEvent)) #8 /var/www/utgpwnew/wire/core/Wire.php(333): Wire->runHooks('processInput', Array) #9 /var/www/utgpwnew/wire/core/InputfieldWrapper.php(636): Wire->__call('processInput', Array) #10 /var/www/utgpwnew/wire/core/Inp in /var/www/utgpwnew/index.php on line 248

If the image field is empty, I get this error on submit

Fatal error: Call to a member function path() on a non-object in /var/www/utgpwnew/wire/modules/Fieldtype/FieldtypeFile.module on line 119

If I change the image field to hold more than one image, I don't get the error and the form submits fine with and without one or more images in the field

From debugging I see that the error is triggered from 

$form->processInput($this->input->post);

So the code does not work on single image fields. Is there a way to fix this?

Any help would be much appreciated.

Link to comment
Share on other sites

@Mats

thank you, but that does not quite apply to my situation.

But I just found the solution:

In the single image field settings in Details tab, I needed to switch from

"Single item (null if empty)"

to

"Array of items"

Now I can use the single image min my frontend form :)

Somehow the processInput method can only handle arrays for file fields

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...