fix selectbox is not resettable (#901)
This commit is contained in:
@@ -232,7 +232,8 @@ class SystemConfigurationController extends AbstractController
|
|||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('theme.select_type')
|
->setName('theme.select_type')
|
||||||
->setTranslationDomain('system-configuration')
|
->setTranslationDomain('system-configuration')
|
||||||
->setType(EnhancedSelectboxType::class),
|
->setType(EnhancedSelectboxType::class)
|
||||||
|
->setRequired(false),
|
||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('timesheet.markdown_content')
|
->setName('timesheet.markdown_content')
|
||||||
->setLabel('theme.markdown_content')
|
->setLabel('theme.markdown_content')
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace App\Form\Model;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
class Configuration
|
final class Configuration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@@ -32,29 +32,26 @@ class Configuration
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $type;
|
private $type;
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $enabled = true;
|
private $enabled = true;
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $required = true;
|
||||||
/**
|
/**
|
||||||
* @var Constraint[]
|
* @var Constraint[]
|
||||||
*/
|
*/
|
||||||
protected $constraints = [];
|
private $constraints = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setName(string $name): Configuration
|
||||||
* @param string $name
|
|
||||||
* @return Configuration
|
|
||||||
*/
|
|
||||||
public function setName(string $name)
|
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
@@ -73,64 +70,43 @@ class Configuration
|
|||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return Configuration
|
* @return Configuration
|
||||||
*/
|
*/
|
||||||
public function setValue($value)
|
public function setValue($value): Configuration
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getType(): ?string
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getType(): string
|
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setType(string $type): Configuration
|
||||||
* @param string $type
|
|
||||||
* @return Configuration
|
|
||||||
*/
|
|
||||||
public function setType(string $type)
|
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isEnabled(): bool
|
public function isEnabled(): bool
|
||||||
{
|
{
|
||||||
return $this->enabled;
|
return $this->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setEnabled(bool $enabled): Configuration
|
||||||
* @param bool $enabled
|
|
||||||
* @return Configuration
|
|
||||||
*/
|
|
||||||
public function setEnabled(bool $enabled)
|
|
||||||
{
|
{
|
||||||
$this->enabled = $enabled;
|
$this->enabled = $enabled;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getLabel(): ?string
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getLabel()
|
|
||||||
{
|
{
|
||||||
return $this->label;
|
return $this->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setLabel(string $label): Configuration
|
||||||
* @param string $label
|
|
||||||
* @return Configuration
|
|
||||||
*/
|
|
||||||
public function setLabel(string $label)
|
|
||||||
{
|
{
|
||||||
$this->label = $label;
|
$this->label = $label;
|
||||||
|
|
||||||
@@ -149,29 +125,34 @@ class Configuration
|
|||||||
* @param Constraint[] $constraints
|
* @param Constraint[] $constraints
|
||||||
* @return Configuration
|
* @return Configuration
|
||||||
*/
|
*/
|
||||||
public function setConstraints(array $constraints)
|
public function setConstraints(array $constraints): Configuration
|
||||||
{
|
{
|
||||||
$this->constraints = $constraints;
|
$this->constraints = $constraints;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getTranslationDomain(): string
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTranslationDomain()
|
|
||||||
{
|
{
|
||||||
return $this->translationDomain;
|
return $this->translationDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setTranslationDomain(string $translationDomain): Configuration
|
||||||
* @param string $translationDomain
|
|
||||||
* @return Configuration
|
|
||||||
*/
|
|
||||||
public function setTranslationDomain(string $translationDomain)
|
|
||||||
{
|
{
|
||||||
$this->translationDomain = $translationDomain;
|
$this->translationDomain = $translationDomain;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isRequired(): bool
|
||||||
|
{
|
||||||
|
return $this->required;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRequired(bool $required): Configuration
|
||||||
|
{
|
||||||
|
$this->required = $required;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class EnhancedSelectboxType extends AbstractType
|
|||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'label' => 'label.select_type',
|
'label' => 'label.select_type',
|
||||||
'choices' => [
|
'choices' => [
|
||||||
'' => null,
|
'' => '',
|
||||||
'Javascript' => 'selectpicker',
|
'Javascript' => 'selectpicker',
|
||||||
],
|
],
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class SystemConfigurationType extends AbstractType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required = true;
|
$required = $preference->isRequired();
|
||||||
if (CheckboxType::class == $preference->getType()) {
|
if (CheckboxType::class == $preference->getType()) {
|
||||||
$required = false;
|
$required = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
|
|||||||
$client->submit($form, [
|
$client->submit($form, [
|
||||||
'system_configuration_form_theme' => [
|
'system_configuration_form_theme' => [
|
||||||
'configuration' => [
|
'configuration' => [
|
||||||
['name' => 'theme.select_type', 'value' => '1'],
|
['name' => 'theme.select_type', 'value' => 'selectpicker'],
|
||||||
['name' => 'timesheet.markdown_content', 'value' => 1],
|
['name' => 'timesheet.markdown_content', 'value' => 1],
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user