mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW Tweak TextField Tip API to match changes to component
This commit is contained in:
parent
a44bc5bcf3
commit
efc7ba9520
@ -27,20 +27,15 @@ class TextField extends FormField
|
|||||||
protected $tipMessage = '';
|
protected $tipMessage = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool Whether the Tip should open immediately
|
* @var string How important the tip is (normal or high). Informs the color and description.
|
||||||
*/
|
*/
|
||||||
protected $tipOpenByDefault = false;
|
protected $tipImportance = 'normal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string The icon that should be used on the Tip button
|
* @var string The icon that should be used on the Tip button
|
||||||
*/
|
*/
|
||||||
protected $tipIcon = 'lamp';
|
protected $tipIcon = 'lamp';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string The Bootstrap color that the icon should be rendered in (e.g. warning, danger, success)
|
|
||||||
*/
|
|
||||||
protected $tipIconColor = 'muted';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an input field.
|
* Returns an input field.
|
||||||
*
|
*
|
||||||
@ -90,25 +85,23 @@ class TextField extends FormField
|
|||||||
* Currently only supported in React-based TextFields.
|
* Currently only supported in React-based TextFields.
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param boolean $openByDefault Whether the Tip should open immediately
|
* @param null|string $importance How important the tip is (normal or high); Informs the color and description
|
||||||
* @param string $icon An icon from the SilverStripe icon font
|
* @param string $icon An icon from the SilverStripe icon font
|
||||||
* @param null $iconColor A text colour defined by Bootstrap (e.g. warning, danger, success)
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function enableTip($message, $openByDefault = false, $icon = null, $iconColor = null)
|
public function enableTip($message, $importance = null, $icon = null)
|
||||||
{
|
{
|
||||||
$this->tipEnabled = true;
|
$this->tipEnabled = true;
|
||||||
$this->tipMessage = $message;
|
$this->tipMessage = $message;
|
||||||
$this->tipOpenByDefault = $openByDefault;
|
|
||||||
|
if ($importance) {
|
||||||
|
$this->tipImportance = $importance;
|
||||||
|
}
|
||||||
|
|
||||||
if ($icon) {
|
if ($icon) {
|
||||||
$this->tipIcon = $icon;
|
$this->tipIcon = $icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($iconColor) {
|
|
||||||
$this->tipIconColor = $iconColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,10 +144,9 @@ class TextField extends FormField
|
|||||||
|
|
||||||
if ($this->tipEnabled) {
|
if ($this->tipEnabled) {
|
||||||
$data['tip'] = [
|
$data['tip'] = [
|
||||||
'icon' => $this->tipIcon,
|
|
||||||
'iconColor' => $this->tipIconColor,
|
|
||||||
'content' => $this->tipMessage,
|
'content' => $this->tipMessage,
|
||||||
'autoOpen' => $this->tipOpenByDefault,
|
'importance' => $this->tipImportance,
|
||||||
|
'icon' => $this->tipIcon,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user