+(defmethod present-slot ((slot many-to-many-slot-presentation) instance)
+
+ (let ((instances (slot-value instance (slot-name slot))))
+ (<:ul
+ (<:li (<ucw:a :action (add-on-many-to-many slot instance)
+ (<:as-html "Add New")))
+ (dolist* (i instances)
+ (<:li
+ (<ucw:a :action (call-view ((car i) (action-view slot) slot))
+ (<:as-html "(view) "))
+ (<ucw:a :action (delete-item (ucw::parent slot) (second i))
+ (<:as-html "(remove) "))
+ (present-view ((car i) (list-view slot) (ucw::parent slot)))) ))))
+
+(defaction add-on-many-to-many ((slot many-to-many-slot-presentation) instance)
+ (let* (new
+ (imd (getf (meta-model::find-slot-metadata instance (slot-name slot))
+ :db-info))
+ (jc (make-instance (getf imd :join-class)))
+ (jcmd (getf (meta-model::find-slot-metadata jc (getf imd :target-slot))
+ :db-info))
+ (fc (make-instance (getf jcmd :join-class)))
+ (c (call-view (fc :creator (ucw::parent slot)))))
+
+ (when c
+ (sync-instance c)
+ (setf (slot-value jc (getf imd :foreign-key))
+ (slot-value instance (getf imd :home-key)))
+ (setf (slot-value jc (getf jcmd :home-key))
+ (slot-value c (getf jcmd :foreign-key)))
+ (sync-instance jc)
+ (sync-instance instance)
+ c)))
+
+
+