(defview scope-form-view (:type form :inherit-from '(:scaffold scope))
(owner :present-as (dropdown :choices #'all-users) :parse-as user)
(parent :present-as (dropdown :choices #'all-scopes) :parse-as scope))
as well as a presentation class and a parser class. This works fine when
adding a new scope object, but not when editing an existing one. When
editing an existing one I get this error:
SIMPLE-ERROR: There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION ATTRIBUTIZE-NAME (4)> when called with
arguments (#<USER {1003D7CC11}>).
I've spent a few hours poking around, losing myself in the usual twisty
maze, and I can't figure out what's going on. formview.lisp defines a
with-view-header method that calls (attributize-name (object-view-class
obj)), but there's no way that would end up calling attributize-name on
a list of user objects. If obj were a list it would end up calling
attributize-name on the symbol cons. What am I missing? What's the
difference between a form-view that's showing me an existing object and
one that's showing me me a newly-minted object?
db48x
> SIMPLE-ERROR: There is no applicable method for the generic function
> #<STANDARD-GENERIC-FUNCTION ATTRIBUTIZE-NAME (4)> when called with
> arguments (#<USER {1003D7CC11}>).
Ok, I spent a little more time on it and figured it out. The problem I'm
having comes from the method render-view-field-value specialized for the
dropdown-presentation (in views/types/presentations/dropdown.lisp). It
calls attributize-name on the value to be rendered in order to render
the dropdown with the correct item selected. However, when the slot it's
rendering a field for contains an object then this isn't the best
approach. If I make it call (presentation-choices-default-value-key
value) then it works perfectly. Because
presentation-choices-default-value-key calls attributize-name for values
that aren't objects, I think this is the right behavior in all cases.
db48x
> Care to post a patch for this one? This will make it easier for me to
> understand
> and review it.
Sure. I set it up on bitbucket.org, but here's the diff in case you
prefer it. It's not a very large change :)
diff -r ea298f9a600b src/views/types/presentations/dropdown.lisp
--- a/src/views/types/presentations/dropdown.lisp Mon Sep 07 16:50:06 2009 +0200
+++ b/src/views/types/presentations/dropdown.lisp Tue Sep 29 11:10:14 2009 -0500
@@ -33,6 +33,6 @@
:selected-value (if intermediate-value-p
intermediate-value
(when value
- (attributize-name value)))
+ (presentation-choices-default-value-key value)))
:id *presentation-dom-id*)))
> I guess it doesn't break any tests?
No, it does not.