silverstripe-framework/src/Forms/SelectionGroup_Item.php

57 lines
1023 B
PHP
Raw Normal View History

<?php
namespace SilverStripe\Forms;
class SelectionGroup_Item extends CompositeField
{
2016-11-29 00:31:16 +01:00
/**
* @var String
*/
protected $value;
/**
* @var String
*/
protected $title;
/**
2020-12-21 22:23:23 +01:00
* @param string $value Form field identifier
2016-11-29 00:31:16 +01:00
* @param FormField|array $fields Contents of the option
2020-12-21 22:23:23 +01:00
* @param string $title Title to show for the radio button option
2016-11-29 00:31:16 +01:00
*/
function __construct($value, $fields = null, $title = null)
{
$this->setValue($value);
if ($fields && !is_array($fields)) {
$fields = [$fields];
2016-11-29 00:31:16 +01:00
}
parent::__construct($fields);
$this->setTitle($title ?: $value);
}
function getTitle()
{
return $this->title;
}
function setTitle($title)
{
$this->title = $title;
return $this;
}
function getValue()
{
return $this->value;
}
function setValue($Value, $data = null)
2016-11-29 00:31:16 +01:00
{
$this->value = $Value;
return $this;
}
}