Browse Source

Add required attribute to CRUD form dropdown

master
Riyyi 4 years ago
parent
commit
4f6894062c
  1. 2
      app/model/PageModel.php
  2. 2
      app/views/admin/crud/create.php
  3. 2
      app/views/admin/crud/edit.php

2
app/model/PageModel.php

@ -67,7 +67,7 @@ class PageModel extends Model {
// Pull sections from cache
$sections = Db::getSections();
return [0 => 'Select section'] + array_combine(
return ['' => 'Select section'] + array_combine(
array_column($sections, 'id'),
array_column($sections, 'title')
);

2
app/views/admin/crud/create.php

@ -43,7 +43,7 @@
<?php } else if ($attribute[1] == 'dropdown') { ?>
<select name="<?= $name; ?>" class="custom-select">
<select name="<?= $name; ?>" class="custom-select" <?= $required; ?>>
<?php foreach($this->dropdownData[$key] as $dropdownKey => $value) { ?>
<option value="<?= $dropdownKey; ?>"><?= $value; ?></option>
<?php } ?>

2
app/views/admin/crud/edit.php

@ -45,7 +45,7 @@
<?php } else if ($attribute[1] == 'dropdown') { ?>
<select name="<?= $name; ?>" class="custom-select">
<select name="<?= $name; ?>" class="custom-select" <?= $required; ?>>
<?php foreach($this->dropdownData[$key] as $dropdownKey => $value) { ?>
<option value="<?= $dropdownKey; ?>"
<?= $this->model->$name == $dropdownKey ? 'selected' : ''; ?>>

Loading…
Cancel
Save