Form processing not working

Author Message

Xavier Serna

Tuesday 12 December 2006 1:34:22 am

Hi all,

this is my first message to the forum, so I apologize if this question has been discussed previously, but I didn't find any solution to this.

My problem is that I have a custom form created, and every time I submit it, I only get the form reloaded, without any errors or debug messages. Simply, the form is not processed, but I can't figure why. The only thing that I can suppose that is causing this, can be that in the form, there are missing fields from the class (in the class there are now attribs that are not used by the moment), but I can't find anywhere if this is required or not that all attribs from the class set up as information collectors need to be present in the form.

Thanks in advance for your support.
Xavier

--
Xavier Serna
eZ Publish Certified Developer
Departament de Software
Microblau S.L. - http://www.microblau.net
+34 937 466 205

Claudia Kosny

Wednesday 13 December 2006 12:20:00 pm

Hi Xavier

First check that the action attribute of your form is correct. If you use some form processing capabilities of EZ make sure that the name of your submit button is correct. EZ often decides on what to do depending of the name of the button and if it does not find any match, it might well just reload the page.

Also enable debug redirection, which will tell you if you are redirected to another page. This is usually the case of you post to e.g. content/action.

If there is no input for fields that are marked as required, you should get some error messages. Maybe your template does not display them anymore? Usually the error messages are in the variable $validation.attributes, although this might not be always the case.
Required fields are marked as required if you edit an object in the admin view. You can also check the class definition of the object in question, each attribute has a checkbox for the required status there.

If you still have problems, post the relevant part of your form (form tag, submit button(s) and a few sample form fields) here and describe what you expect to happen on submit.

Claudia

Xavier Serna

Thursday 14 December 2006 12:39:01 am

Hi Claudia,

thanks for your answer. I think that I've found the problem. If I put all the Information Collector fields in the form, it works correctly as expected. The problem is if I don't need/want to put some of the fields. If there are some missing fields, present in the class as attributes, but not present in the actual form, the form is not processed, and we don't get any validation errors or something similar. I suppose that including the missing fields as hidden input fields it will work correctly. The question is if it is the correct way to get the form working, or there is another procedure for that?
The action of the form is "content/action" and the submit button name is: ActionCollectInformation

thanks for your support!!

--
Xavier Serna
eZ Publish Certified Developer
Departament de Software
Microblau S.L. - http://www.microblau.net
+34 937 466 205

Claudia Kosny

Thursday 14 December 2006 2:36:39 am

Hi Xavier

I think the problem occurs because some datatypes do not validate correctly. E.g. ezstring, eztext and ezdate automatically return an EZ_INPUT_VALIDATOR_STATE_INVALID (without setting any validation error) if the respective post variables are not there, no matter whether the attribute is required or not.

I don't have the time right now to see whether this is really the source of the problem, so if you have the time to check this and confirm this you should maybe post a bug report. For a quick solution I would just do as you said before and post the attributes as hidden fields.

Claudia

Xavier Serna

Thursday 14 December 2006 9:32:04 am

Hi again Claudia,

after some testing, I've found that the problem is that when a missing classattribute is found, it returns as you say, EZ_INPUT_VALIDATOR_STATE_INVALID, and then in collectinformation.php sets the $canCollect to false without checking if the attribute has content or not, or is required or not, so, as the attribute has no content, it have the $hasValidationError set to false, so it don't generate any error message.
I've found that including a simple check to see if the attribute has content or is required, the problem is solved.

I've changed this line in collectinformation.php from

            else if ( $status == EZ_INPUT_VALIDATOR_STATE_INVALID )

to this one

            else if ( $status == EZ_INPUT_VALIDATOR_STATE_INVALID && ($contentObjectAttribute->attribute( 'has_content' ) || $contentObjectAttribute->attribute( 'is_required' )) )

and now the form is processed correctly and the object information is collected, obviously without any attributes that you don't have put in the form.

I don't know if it is a bug or a feature :s

kind regards!

--
Xavier Serna
eZ Publish Certified Developer
Departament de Software
Microblau S.L. - http://www.microblau.net
+34 937 466 205

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.