Ticket #13567 (confirmed Bug)

Opened 3 years ago

Last modified 3 years ago

InlineValidation broken for MultiWidget

Reported by: ua_trac_plone@… Owned by:
Priority: minor Milestone: 4.x
Component: General Version: 4.3
Keywords: plone.app.form, zope.z3cform Cc:

Description

Currently, InlineValidation relies on the data-fieldname attribute being set for a correct ajax request to @@z3cform_validate_field.

Unfortunately, with MultiWidget, no data-fieldname attribute is set, resulting in:

(Pdb) 2013-05-06 15:08:46 ERROR Zope.SiteErrorLog
1367845726.760.216313396438
http://127.0.0.1:8080/test/++add++test.content.product/@@z3cform_validate_field
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 72, in mapply
  Module ZPublisher.Publish, line 51, in missing_name
  Module ZPublisher.HTTPResponse, line 741, in badRequestError
BadRequest:   <h2>Site Error</h2>
  <p>An error was encountered while publishing this resource.
  </p>
  <p><strong>Invalid request</strong></p>

  The parameter, <em>fname</em>, was omitted from the request.<p>Make
sure to specify all required parameters, and try the request again.</p>
  <hr noshade="noshade"/>

  <p>Troubleshooting Suggestions</p>

  <ul>
  <li>The URL may be incorrect.</li>
  <li>The parameters passed to this resource may be incorrect.</li>
  <li>A resource that this resource relies on may be
      encountering an error.</li>
  </ul>

  <p>For more detailed information about the error, please
  refer to the error log.
  </p>

  <p>If the error persists please contact the site maintainer.
  Thank you for your patience.
  </p>
>
/home/xxx/.buildout/eggs/Zope2-2.13.19-py2.7.egg/ZPublisher/HTTPResponse.py(741)badRequestError()
-> "and try the request again.</p>"

An easy test case (Dexterity w/o grok):

from zope import schema

from plone.supermodel import model
from plone.autoform import directives as form

from test.content import _

class ITestBlock(model.Schema):
    title = schema.TextLine(title=_(u"Block Title"),)
    some_text = schema.TextLine(title=_(u"Test Text"),)

class IProduct(model.Schema):
    title = schema.TextLine(
        title=_(u"Product name"),
    )

    sections = schema.List(
       title=_(u"Section Blocks"),
       value_type=schema.Object(schema=ITestBlock)
    )

While in the add Product form, add a section block and click on the block title. After leaving that field, the inline validation kicks in and the badRequestError() happens due to the missing field name.

Change History

comment:1 Changed 3 years ago by kleist

  • Status changed from new to confirmed
  • Component changed from Unknown to General

comment:2 Changed 3 years ago by sunew

Fixed (a pull request is pending) on master of plone.app.z3cform.

comment:3 Changed 3 years ago by seanupton

This problem can be fixed widget-by-widget, but there is a "robustness principle" problem in inline_validation.js, if it will trust the DOM. If fname is undefined, null, or empty, the AJAX request should not be sent. See #13741

Note: See TracTickets for help on using tickets.