View_List: list.php
View_Edit: edit.php
Controller: configuration.php
find_all();
$view_configuration_list = View::factory('backend/configuration/list')->set("ls_configuration", $ls_configuration);
$this->template->set('content', $view_configuration_list);
}
public function action_new(){
$this->action_edit(FALSE);
}
public function action_edit($edit = TRUE){
$this->auto_render = FALSE;
$valid = Validation::factory($this->request->post())
->rule('key', 'not_empty')
->rule('value', 'not_empty');
$id = $edit ? $this->request->param('id') : NULL;
$rs_configuration = ORM::factory('config_configuration', $id);
if ($this->request->method() == 'POST') {
$rs_configuration->values($this->request->post());
if ($valid->check()) {
$rs_configuration->save();
$this->request->redirect('backend/configuration/list');
}
}
$content = View::factory('backend/configuration/edit')
->set('rs_configuration', $rs_configuration);
$this->response->body($content);
}
public function action_delete() {
if(!$id = $this->request->param('id')){
$this->request->redirect('backend/configuration/list');
}
$rs_configuration = ORM::factory('config_configuration', $id);
//$rs_configuration->delete();
$this->request->redirect('backend/configuration/list');
}
}
JS – JQuery
$(document).ready(function() {
/* ---------- Modal forms ---------- */
$('a[data-toggle=modal-form]').modalForm();
});
/*
- ---------- Extending jQuery ----------
*/
$.fn.extend({
modalForm: function () {
$(this).click(function (e) {
var $this = $(this);
var $href = $this.attr('href');
var $target = $($this.data('target'));
e.preventDefault();
$target.load($href, function (response, status, xhr) {
if(status == 'error') {
alert(xhr.responseText);
} else {
$target.modal('show')
.on('shown', function () { $('body').css('overflow', 'hidden'); })
.on('hide', function () { $('body').css('overflow', 'visible'); });
}
});
})
}
});