mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
5c9044a007
API Introduce HTMLFragment as casting helper for HTMLText with shortcodes disabled API Introduce DBField::CDATA for XML file value encoding API RSSFeed now casts from the underlying model rather than by override API Introduce CustomMethods::getExtraMethodConfig() to allow metadata to be queried BUG Remove _call hack from VirtualPage API Remove FormField::$dontEscape API Introduce HTMLReadonlyField for non-editable readonly HTML API FormField::Field() now returns string in many cases rather than DBField instance. API Remove redundant *_val methods from ViewableData API ViewableData::obj() no longer has a $forceReturnObject parameter as it always returns an object BUG Fix issue with ViewableData caching incorrect field values after being modified. API Remove deprecated DB class methods API Enforce plain text left/right formfield titles
96 lines
2.3 KiB
PHP
96 lines
2.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Render a button that will submit the form its contained in through ajax.
|
|
* If you want to add custom behaviour, please set {@link includeDefaultJS()} to FALSE
|
|
*
|
|
* @see framework/client/dist/js/InlineFormAction.js
|
|
*
|
|
* @package forms
|
|
* @subpackage actions
|
|
*/
|
|
class InlineFormAction extends FormField {
|
|
|
|
protected $includeDefaultJS = true;
|
|
|
|
/**
|
|
* 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;
|
|
parent::__construct($action, $title);
|
|
}
|
|
|
|
public function performReadonlyTransformation() {
|
|
return $this->castedCopy('InlineFormAction_ReadOnly');
|
|
}
|
|
|
|
/**
|
|
* @param array $properties
|
|
* @return string
|
|
*/
|
|
public function Field($properties = array()) {
|
|
if($this->includeDefaultJS) {
|
|
Requirements::javascriptTemplate(
|
|
FRAMEWORK_DIR . '/client/dist/js/InlineFormAction.js',
|
|
array('ID'=>$this->ID())
|
|
);
|
|
}
|
|
|
|
return FormField::create_tag('input', array(
|
|
'type' => 'submit',
|
|
'name' => sprintf('action_%s', $this->getName()),
|
|
'value' => $this->title,
|
|
'id' => $this->ID(),
|
|
'class' => sprintf('action%s', $this->extraClass),
|
|
));
|
|
}
|
|
|
|
public function Title() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Optionally disable the default javascript include (framework/client/dist/js/InlineFormAction.js),
|
|
* which routes to an "admin-custom"-URL.
|
|
*
|
|
* @param $bool boolean
|
|
*/
|
|
public function includeDefaultJS($bool) {
|
|
$this->includeDefaultJS = (bool)$bool;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Readonly version of {@link InlineFormAction}.
|
|
* @package forms
|
|
* @subpackage actions
|
|
*/
|
|
class InlineFormAction_ReadOnly extends FormField {
|
|
|
|
protected $readonly = true;
|
|
|
|
/**
|
|
* @param array $properties
|
|
* @return string
|
|
*/
|
|
public function Field($properties = array()) {
|
|
return FormField::create_tag('input', array(
|
|
'type' => 'submit',
|
|
'name' => sprintf('action_%s', $this->name),
|
|
'value' => $this->title,
|
|
'id' => $this->ID(),
|
|
'disabled' => 'disabled',
|
|
'class' => 'action disabled ' . $this->extraClass,
|
|
));
|
|
}
|
|
|
|
public function Title() {
|
|
return false;
|
|
}
|
|
}
|