public function renderSubmitButtons() { if ($this->item->id()) { echo '<a class="btn btn-primary" ' . 'href="/admin/' . $this->controllerAlias . '/new/">Add new</a> '; echo '<a class="btn btn-danger js-delete-item" ' . 'href="/admin/' . $this->controllerAlias . '/delete/' . $this->item->id() . '">Delete</a> '; } $name = $this->item->id() ? 'Save' : 'Add'; echo '<button class="btn btn-primary" type="submit">' . $name . '</button> '; }
public function renderSubmitButtons() { if ($this->item->id()) { echo '<a class="btn btn-primary" ' . 'href="/admin/' . $this->controllerAlias . '/new/">Добавить новый</a> '; echo '<a class="btn btn-danger js-delete-item" ' . 'href="/admin/' . $this->controllerAlias . '/delete/' . $this->item->id() . '">Удалить</a> '; } $name = $this->item->id() ? 'Сохранить' : 'Добавить'; echo '<button class="btn btn-primary" type="submit">' . $name . '</button> '; }
protected function removeExistingFile(BaseModel $item, $field, array $options) { if (!$item->id()) { return; } $existingFile = $item->{$field}; $absPath = $options['abs_path'] ? $options['dir_path'] : $this->pixie->root_dir . 'web/' . preg_replace('|^/+|', '', $options['dir_path']) . $existingFile; if (file_exists($absPath) && is_file($absPath) && is_writable($absPath)) { unlink($absPath); } $item->{$field} = ''; }