1 <?php
2 3 4 5 6
7 class ImageFormAction extends FormAction {
8 protected $image, $hoverImage, $className;
9
10 11 12 13 14 15 16 17
18 function __construct($action, $title = "", $image = "", $hoverImage = null, $className = null, $form = null) {
19 $this->image = $image;
20 $this->hoverImage = $hoverImage;
21 $this->className = $className;
22 parent::__construct($action, $title, $form);
23 }
24 function Field() {
25 Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
26 Requirements::javascript(SAPPHIRE_DIR . '/javascript/ImageFormAction.js');
27
28 $classClause = '';
29 if($this->className) $classClause = $this->className . ' ';
30 if($this->hoverImage) $classClause .= 'rollover ';
31 return "<input class=\"{$classClause}action\" id=\"" . $this->id() . "\" type=\"image\" name=\"{$this->name}\" src=\"{$this->image}\" title=\"{$this->title}\" alt=\"{$this->title}\" />";
32 }
33 }
34
35 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-