silverstripe-framework/Forms/InlineFormAction.php

51 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace SilverStripe\Forms;
use SilverStripe\View\Requirements;
/**
* Render a button that will submit the form its contained in through ajax.
2014-08-15 08:53:05 +02:00
*
* Caution: The form field does not include any JavaScript or CSS when used outside of the CMS context,
* since the required frontend dependencies are included through CMS bundling.
*
* @see framework/client/dist/js/InlineFormAction.js
*/
class InlineFormAction extends FormField {
2014-08-15 08:53:05 +02:00
/**
* Create a new action button.
*
* @param string $action The method to call when the button is clicked
* @param string $title The label on the button
* @param string $extraClass A CSS class to apply to the button in addition to 'action'
*/
public function __construct($action, $title = "", $extraClass = '') {
$this->extraClass = ' '.$extraClass;
2015-10-28 04:44:14 +01:00
parent::__construct($action, $title);
}
2014-08-15 08:53:05 +02:00
public function performReadonlyTransformation() {
return $this->castedCopy('SilverStripe\\Forms\\InlineFormAction_ReadOnly');
}
2014-08-15 08:53:05 +02:00
2015-06-20 12:11:08 +02:00
/**
* @param array $properties
* @return string
2015-06-20 12:11:08 +02:00
*/
public function Field($properties = array()) {
return FormField::create_tag('input', array(
2015-10-28 04:44:14 +01:00
'type' => 'submit',
2015-06-20 12:11:08 +02:00
'name' => sprintf('action_%s', $this->getName()),
'value' => $this->title,
'id' => $this->ID(),
'class' => sprintf('action%s', $this->extraClass),
));
2014-08-15 08:53:05 +02:00
}
public function Title() {
2014-08-15 08:53:05 +02:00
return false;
}
}