Source of file GridFieldLinkButton.php
Size: 1,430 Bytes - Last Modified: 2021-12-24T06:34:24+00:00
/var/www/docs.ssmods.com/process/src/src/Forms/GridFieldLinkButton.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php namespace BringYourOwnIdeas\Maintenance\Forms; use SilverStripe\Forms\GridField\GridField; use SilverStripe\View\ArrayData; use SilverStripe\Forms\GridField\GridField_HTMLProvider; /** * A button that contains a link to an URL. * * @package forms * @subpackage fields-gridfield */ class GridFieldLinkButton implements GridField_HTMLProvider { /** * Fragment to write the button to. * @var string */ protected $targetFragment; /** * URL link the button links out to. * @var string */ protected $link; /** * Caption text for the button to show * @var string */ protected $caption; /** * @param string $link The URL link the button links out to. * @param string $targetFragment The HTML fragment to write the button into */ public function __construct($link, $caption, $targetFragment) { $this->link = $link; $this->caption = $caption; $this->targetFragment = $targetFragment; } /** * Place the link button in a <p> tag above the field * * @param GridField $gridField * * @return array */ public function getHTMLFragments($gridField) { $fragment = ArrayData::create([ 'Link' => $this->link, 'Caption' => $this->caption, ])->renderWith(__CLASS__); return [$this->targetFragment => $fragment]; } } |