suppose i want a page with a bunch of fields, and two buttons, ok an apply. if user push apply, form contents just sent into db, but if user click ok, he also redirected to previous page.
how can i check which button user clicked ? (value (ok-button test)) always returns empty string.
example code:
(defcomponent test (widget-component)
((field :accessor field :initform (make-instance 'string-field))
(apply-button :accessor apply-button
:initform (make-instance 'submit-button :label "Apply"))
(ok-button :accessor ok-button
:initform (make-instance 'submit-button :label "OK")))
(:render ()
(<:div (<ucw:form :action (progn
(update-some-db :field (field test))
(if (value (ok-button test))
(return-to-upper-level)))
(render (field test))
(render (apply-button test))
(render (ok-button test))))))
if i try to use <ucw:submit :action (setf (button-clicked test) t),
this action does not execute, ucw:form's :action executed instead.
if i remove ucw:form's :action, nothing executes at all on submit.
(defmethod render ((field submit-button))
(<ucw:submit :id (dom-id field)
:accesskey (accesskey field)
:name (name field)
:title (tooltip field)
:tabindex (tabindex field)
:writer (lambda (v)
(setf (client-value field) v))
:reader (label field)
:class (css-class field)
:style (css-style field)))
(defclass submit-button (generic-html-input)
((label :accessor label :initform nil :initarg :label))
(:default-initargs :client-value nil))