Anonymous avatar Anonymous committed 37bd0ab

contrib/lpolzer: misc. fixes to form-widget.

Comments (0)

Files changed (1)

contrib/lpolzer/form-widget.lisp

           validators-of
           on-success-of
           reset-form-widget
+          render-confirmation
+          render-form-controls
           find-field-widget-by-name
           form-value
 	  with-form-values
           pretty-intermediate-value-of
           parsed-value-of
           error-message-of
+          error-messages-of
           render-field
           render-field-contents
           update-form-field-value-from-request
 (defmethod reset-form-widget ((widget form-widget))
   ;; This can get complicated when fields are modified
   ;; dynamically. In that case specialize this method.
-  (mapcar (lambda (field)
-            (setf (intermediate-value-of field) nil)
-            (setf (parsed-value-of field) nil))
-          (widget-children widget)))
+  (setf (state-of widget) :form)
+  (setup-fields widget))
 
 (defmethod render-widget-body ((widget form-widget) &rest args)
   (declare (ignore args))
 (defmethod update-field-widgets-parent ((widget form-widget))
   (mapc (lambda (field) (setf (form-of field) widget)) (fields-of widget)))
 
+(defmethod render-form-controls ((widget form-widget))
+  (with-html
+    (:input :type "submit" :value "Submit")))
+
 (defmethod render-widget-children ((widget form-widget) &rest args)
   (declare (ignore args))
   (when (eq (state-of widget) :form)
         (:div :class "fields"
           (mapc #'render-widget fields))
         (:div :class "controls"
-          (:input :type "submit" :value "Submit"))))))
+          (render-form-controls widget))))))
 
 (defmethod render-widget-children :after ((widget form-widget) &rest args)
   (declare (ignore args))
       ((and raw-value (not empty)) ; present, parse it
        (multiple-value-bind (parsed-successfully-p parsed-value-or-error-message)
            (funcall (parser-of field) raw-value)
-         #+leslie(format t "parser returned ~S~%" parsed-value-or-error-message)
+         #+leslie(format t "parser ~S returned ~S~%" (parser-of field) parsed-value-or-error-message)
          (if parsed-successfully-p
            (let ((validation-errors (mapcar #'cadr
                                             (remove-if #'identity ; remove passed validator results
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.