Hi, Anyone written an image button form element module? It's easy, I am just sooo lazy :) Regards NK
Anyone written an image button form element module?
For Goodstorm we tried using image inputs for form submission, but abandoned the approach. It seemed like a misuse of the image input type, which is intended to pass an x,y coordinate. This is the code we used. /** * Format an image input. * * This element type is used to substitute a graphic for a regular form submit button. * * @param $element * An associative array containing the properties of the element. * @return * A themed HTML string representing the image input. */ function theme_select_image($element) { return '<input type="image" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ') .'value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n"; } // Sample usage. $form['submit'] = array( '#type' => 'submit_image', '#value' => t('Submit'), '#name'=> 'submit', '#attributes' => array('src' => 'path/to/image.png') );
Karoly Negyesi wrote:
Hi,
Anyone written an image button form element module? It's easy, I am just sooo lazy :)
There's one in views.module Note that image buttons have some issues that make it difficult to just replace them, *but* I think a simple #after_build could actually fix that. (You can't use $op on an image_button because IE buggily does not return any kind of value for the image button. However, if you check each button directly, you can see which button was pressed. Therefore, the #after_build for each button could say "Hey I was pressed" and set the appropriate value in 'op' before the rest of the form can react.)
Op zaterdag 8 juli 2006 15:17, schreef Karoly Negyesi:
Hi,
Anyone written an image button form element module? It's easy, I am just sooo lazy :)
Or override the CSS input.button { background: url(ok.png); /* ok.png is 22x22 pixels padding-left: 29px; padding-right: 7px; } Thats how you can make nice buttons like the one attached. Bèr
participants (4)
-
Bèr Kessels -
Earl Miles -
Karoly Negyesi -
Nedjo Rogers