ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Is autosave not calling a fieldtype's validate method?

July 13, 2011 6:09pm

Subscribe [2]
  • #1 / Jul 13, 2011 6:09pm

    Brian Litzinger

    711 posts

    See this ticket I filed over at P&T. Appears autosave isn’t calling the validate() method on fieldtypes. Should it be?

  • #2 / Jul 14, 2011 2:27pm

    Kevin Smith

    4784 posts

    Hey Brian,

    Looks like your link didn’t make it into the post. Mind giving us a link to the ticket in question?

  • #3 / Jul 14, 2011 2:38pm

    Brian Litzinger

    711 posts

    Oops. http://help.pixelandtonic.com/brandonkelly/topics/matrix_and_autosave

    I can see why validate on possibly incomplete data would be a bad idea. Maybe the validate method needs to pass a boolean, e.g. $is_autosave, to let devs check against in the fieldtypes?

  • #4 / Jul 15, 2011 1:28pm

    Robin Sowell

    13255 posts

    Right- we don’t want to validate for autosave, as it’s expected to be incomplete data at that point- and errors would be annoying.  I lean toward this being an issue w/the add-on rather than EE.  And it may suggest a need to beef the docs on the api in that regard.

    Am open to discussion, though.  Will keep an eye on the bug report and see what they have to say.

  • #5 / Jul 15, 2011 1:34pm

    Brian Litzinger

    711 posts

    Well, the fieldtype would need to know if autosave is called, so the developer can take the appropriate action.

  • #6 / Jul 15, 2011 2:59pm

    Robin Sowell

    13255 posts

    I’m not entirely sure I agree- but the issue is hairier than I first thought.  Mostly because I’m wrong and it is running validation when autosaving- and not validating prevents autosave from working.  I personally think that’s buggy and have entered a bug report here.

    It goes into some detail and I do include the Matrix issue as something we need to take into account when crafting a fix.  Revisions have some of the same theoretical issue we need give more attention to- particularly when additional tables are involved in storing data.

    Which is a long way of saying- I agree there’s a bug here.  I won’t swear the fix we take will address the Matrix issue directly (as I’m inclined not to validate at first glance- but calling validate w/an autosave indicator and documenting how to use it may be a better option anyway), but however it shakes out, we’ll make sure what’s happening in the docs so that third parties can code w/that in mind. 

    Sorry to be vague- it is a little hairy and I’m not set on a fix yet or I’d have fixed it rather than entering the report.

    Make sense?

  • #7 / Jul 15, 2011 3:07pm

    Brian Litzinger

    711 posts

    Makes sense and sounds good. Will keep an eye on the report.

    Thanks!

  • #8 / Jul 15, 2011 3:48pm

    Kevin Smith

    4784 posts

    Awesome, thanks for bringing it to our attention, Brian! Closing this out since Robin has that bug report filed…

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases