Forum OpenACS Q&A: button image and ad_form

Collapse
Posted by Mark Aufflick on
I'm trying to make an ad_form have an image for a button, and it is proving rediculously difficult.

One approach is to use css and background images. of course for that, I need to be able to specify the class or id of the butotn - which ad_formdoes not provide for.

So I added an element with the widget type = submit and used html to set the class.

VOila - it works. But wait - did I hear someone mention cross-platform compatibility issues?

Sure enough, IE on the mac stuffs up the button size and borders. But who uses ie on the mac any more? Trouble is, Safari ignores the background image css attribute on the button rendering an Aqua native button. Not too bad by itself, but it DOES honour the css size attributes, thus making the button far too small for the aqua button largesse and the button text (which gets truncated).

Back to the drawing board.

Can I use the input widget directly? Well, template::widget::input gets called ok, but with no attributes no matter how hard i try from within the ad_form block.

Is there an image widget? No - not too hard to write so I might do that.

The funny thing is that I really can't be the first person to want to do this - either an image for beauty's sake or actually as an imagemap.

SO has anyone done this? Or does anyone have any opinions about the best way for me to add this to the toolkit?

I would personally like to do two things:

1/ add an imagemap widget for imagemaps
2/ provide the ability to provide a triplet to -buttons indicating the third element is an image url

Collapse
Posted by Mark Aufflick on
1/ proved ultra simple.

added template::widget::image:

ad_proc -public template::widget::image { element_reference tag_attributes } {
  upvar $element_reference element
  return [input image element $tag_attributes]
}
and had to make template::widget::input wise up to the src attribute:

      if { [info exists element(src)] } {                                                                                     
          append output " src=\"$element(src)\""
      }
Who thinks i should commit this?

Collapse
Posted by Jun Yamog on
This looks very useful.  Anyway I hope it gets in.  Maybe you can try the submitting a patch to bug tracker so it gets remembered?
Collapse
Posted by James Thornton on
I have added the code above to add the image button, but ad_form is apparently not recognizing that a submit has occurred because the -after_submit block isn't firing with the image button (it does with the submit button though). Anyone well versed in the ad_form code know how to fix this?
Collapse
Posted by Jorge Couchet on
Hi James,

Have you resolved the problem (I'm interested in the answer)?

Thanks!

Jorge.