trait CubistMagicControllerTrait
{
+ protected $_fields = [];
+
public function setup()
{
if (!$this->_routeURL) {
if ($this->_clonable) {
$this->crud->allowAccess('clone');
}
+
+ if($this->_oneInstance){
+ $this->crud->addClause('where', 'id', 1);
+ $this->crud->denyAccess(['create', 'delete']);
+ }else{
+ $this->crud->setCreateView('cubist_back::create');
+ }
+
$this->crud->allowAccess('revisions');
$this->crud->enablePersistentTable();
- $this->crud->setCreateView('cubist_back::create');
+
$this->crud->setEditView('cubist_back::edit');
+ $this->crud->enableExportButtons();
// $this->crud->with('revisionHistory');
$this->crud->addColumn(['name' => $model->getPrimaryKey(), 'type' => 'number', 'label' => "#", 'searchLogic' => 'text']);
- $this->updateFieldsFromModel();
+ $this->updateFieldsFromModel($model);
}
$model = $this->getModelInstance();
}
foreach ($model->getFields() as $field) {
- if ($this->crud->hasField($field->getAttribute('name'))) {
+ if (isset($this->_fields[$field->getAttribute('name')])) {
continue;
}
$this->addField($field);
$this->crud->addColumn($field->getColumnData());
}
$this->crud->addField($field->getDefinition(), $field->getCRUDForm());
+
+ $this->_fields[$field->getAttribute('name')] = $field;
}
/**
'EXTENDS' => $this->_getBaseController(),
'CLONABLE' => $this->clonable ? 'true' : 'false',
'BULK' => $this->getOption('bulk', true) ? 'true' : 'false',
- ];
+ 'ONEINSTANCE' => $this->getOption('oneinstance', false) ? 'true' : 'false'];
$res = file_get_contents($stub);
foreach ($vars as $name => $value) {
protected $table = 'cubist_settings';
protected $_options = ['name' => 'settings',
- 'singular' => 'setting',
- 'plural' => 'settings'];
+ 'singular' => 'paramètre',
+ 'plural' => 'paramètres',
+ 'oneinstance' => true];
public function setFields()
{