SlideShare a Scribd company logo
Julio Pari - CodigoAgil.com
Bootstrap - Kohana Framework PHP - JQuery
Julio Pari - CodigoAgil.com
View_List: list.php
View_Edit: edit.php
<a data-toggle="modal-form" href="/backend/configuration/edit/<?php echo $rs_configuration->id; ?>" class="btn btn-info" data-target="#modal-form">
<i class="icon-edit icon-white"></i>
</a>
<form action="/backend/configuration/edit/<?php echo $rs_configuration->id ?>" class="form-horizontal" method="POST">
<div class="modal-header">
<button class="btn close" data-dismiss="modal">×</button>
<h2><i class=""></i><span class="break"></span>Editar</h2>
</div>
<div class="modal-body">
<div class="control-group">
<label class="control-label">Clave:</label>
<div class="controls">
<input name="key" id="key" type="text" value="<?php echo $rs_configuration->key; ?>" />
</div>
</div>
<div class="control-group">
<label class="control-label">Valor:</label>
<div class="controls">
<input name="value" id="value" type="text" value="<?php echo $rs_configuration->value; ?>" />
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Cerrar</button>
<input type="submit" value="Guardar" class="btn btn-primary" />
</div>
</form>
Julio Pari - CodigoAgil.com
Controller: configuration.php
<?php
defined('SYSPATH') or die('No direct script access.');
class Controller_Backend_Configuration extends Controller_Backend_Template {
public function action_list() {
$ls_configuration = ORM::factory('config_configuration')->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');
}
}
Julio Pari - CodigoAgil.com
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'); });
}
});
})
}
});

More Related Content

PPTX
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
PPTX
Web Design Course - Lecture 21 - Bootstrap Jumbotron, Thumbnails, Alerts, Pro...
ZIP
引き出しとしてのDjango - SoozyCon7
PPTX
Web Design Course - Lecture 18 - Boostrap, Gatting started, grid system, tables
PPTX
16. CodeIgniter stergerea inregistrarilor
PPTX
24. CodeIgniter simple login with sessions
PPTX
A Two-step Dance with Django and Jinja2 Templates
TXT
Links/Деловой и денежный мир
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
Web Design Course - Lecture 21 - Bootstrap Jumbotron, Thumbnails, Alerts, Pro...
引き出しとしてのDjango - SoozyCon7
Web Design Course - Lecture 18 - Boostrap, Gatting started, grid system, tables
16. CodeIgniter stergerea inregistrarilor
24. CodeIgniter simple login with sessions
A Two-step Dance with Django and Jinja2 Templates
Links/Деловой и денежный мир

What's hot (12)

PPTX
17. CodeIgniter login simplu cu sesiuni
PDF
Engines: Team Development on Rails (2005)
PDF
Technical Preview: The New Shopware Admin
TXT
Trabajo
PDF
Owasp & php
PPTX
23. CodeIgniter sessions
PDF
Flask 소수전공 강의자료 - 2차시
DOC
DOCX
TXT
Fcr 2
TXT
Convidar para page !!
RTF
Documento
17. CodeIgniter login simplu cu sesiuni
Engines: Team Development on Rails (2005)
Technical Preview: The New Shopware Admin
Trabajo
Owasp & php
23. CodeIgniter sessions
Flask 소수전공 강의자료 - 2차시
Fcr 2
Convidar para page !!
Documento
Ad

Viewers also liked (8)

PDF
Prototyping for tiny fingers
PDF
Algoritmica i clase03 practica 3 solucionario
PDF
Rettig onprototyping
PDF
Spredfast pocketguide-final
PPS
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
PDF
Algoritmica i clase06 ejercicio apuntadores
PDF
Amazon dynamo-sosp2007
PDF
Jdeveloper 11g
Prototyping for tiny fingers
Algoritmica i clase03 practica 3 solucionario
Rettig onprototyping
Spredfast pocketguide-final
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
Algoritmica i clase06 ejercicio apuntadores
Amazon dynamo-sosp2007
Jdeveloper 11g
Ad

Similar to Kohana bootstrap - modal form (20)

PDF
Make More Money With Advanced Custom Fields - WordCampYYC 2015
PDF
QCon 2015 - Thinking in components: A new paradigm for Web UI
PDF
Your Custom WordPress Admin Pages Suck
PDF
Index of jquery template 2 Minuteman Summer Web Dev.
PPT
Slimme Joomla! Templating Tips en Truuks
PPT
Clever Joomla! Templating Tips and Tricks
TXT
Copy of-a-walk-around-westfall-plaza
TXT
The project gutenberg e book, fairy tales from brazil, by elsie spicer
PDF
Capstone Website Code
PDF
Vue.js - zastosowanie i budowa komponentów
PPTX
JQuery Mobile UI
PDF
Action View Form Helpers - 1, Season 2
PDF
HTML5 and the dawn of rich mobile web applications pt 2
PDF
Improving state of M2 front-end - Magento 2 Community Project
PDF
Laravel 로 배우는 서버사이드 #5
PDF
Bootstrap day4
PPT
07 Php Mysql Update Delete
TXT
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TXT
Facebook.html
TXT
Facebook.html
Make More Money With Advanced Custom Fields - WordCampYYC 2015
QCon 2015 - Thinking in components: A new paradigm for Web UI
Your Custom WordPress Admin Pages Suck
Index of jquery template 2 Minuteman Summer Web Dev.
Slimme Joomla! Templating Tips en Truuks
Clever Joomla! Templating Tips and Tricks
Copy of-a-walk-around-westfall-plaza
The project gutenberg e book, fairy tales from brazil, by elsie spicer
Capstone Website Code
Vue.js - zastosowanie i budowa komponentów
JQuery Mobile UI
Action View Form Helpers - 1, Season 2
HTML5 and the dawn of rich mobile web applications pt 2
Improving state of M2 front-end - Magento 2 Community Project
Laravel 로 배우는 서버사이드 #5
Bootstrap day4
07 Php Mysql Update Delete
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
Facebook.html
Facebook.html

More from Julio Pari (20)

PPTX
Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
PDF
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
DOCX
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
DOCX
Indice General Tesis Sistemas UPC
PPTX
Arquitectura Web FISI UNMSM
PDF
Jelastic Enterprise
DOCX
Marketing Examen Parcial Profesor Osorio
DOCX
Ingenieria Software Examen Parcial 2013 2 Profesor Cordero
PDF
Documento de Arquitectura
DOCX
Solucion Examen Parcial Sistemas Digitales UNMSM FISI
DOCX
Práctica de Inventarios - Investigación Operativa II
PDF
Armas silenciosas para guerras tranquilas
PDF
UML Java
DOCX
Formato de presentación de Proyecto UNMSM FISI
DOCX
Cuento para nuestro hijo y nuestra hija
DOCX
Ingeniería de Software Examen Parcial
DOCX
Sistemas Distribuidos Examen Parcial
PDF
Php07 consultas bd
PDF
Php06 instalacion my_sql
PDF
Php05 funciones usuario
Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Indice General Tesis Sistemas UPC
Arquitectura Web FISI UNMSM
Jelastic Enterprise
Marketing Examen Parcial Profesor Osorio
Ingenieria Software Examen Parcial 2013 2 Profesor Cordero
Documento de Arquitectura
Solucion Examen Parcial Sistemas Digitales UNMSM FISI
Práctica de Inventarios - Investigación Operativa II
Armas silenciosas para guerras tranquilas
UML Java
Formato de presentación de Proyecto UNMSM FISI
Cuento para nuestro hijo y nuestra hija
Ingeniería de Software Examen Parcial
Sistemas Distribuidos Examen Parcial
Php07 consultas bd
Php06 instalacion my_sql
Php05 funciones usuario

Kohana bootstrap - modal form

  • 1. Julio Pari - CodigoAgil.com Bootstrap - Kohana Framework PHP - JQuery Julio Pari - CodigoAgil.com View_List: list.php View_Edit: edit.php <a data-toggle="modal-form" href="/backend/configuration/edit/<?php echo $rs_configuration->id; ?>" class="btn btn-info" data-target="#modal-form"> <i class="icon-edit icon-white"></i> </a> <form action="/backend/configuration/edit/<?php echo $rs_configuration->id ?>" class="form-horizontal" method="POST"> <div class="modal-header"> <button class="btn close" data-dismiss="modal">×</button> <h2><i class=""></i><span class="break"></span>Editar</h2> </div> <div class="modal-body"> <div class="control-group"> <label class="control-label">Clave:</label> <div class="controls"> <input name="key" id="key" type="text" value="<?php echo $rs_configuration->key; ?>" /> </div> </div> <div class="control-group"> <label class="control-label">Valor:</label> <div class="controls"> <input name="value" id="value" type="text" value="<?php echo $rs_configuration->value; ?>" /> </div> </div> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal">Cerrar</button> <input type="submit" value="Guardar" class="btn btn-primary" /> </div> </form>
  • 2. Julio Pari - CodigoAgil.com Controller: configuration.php <?php defined('SYSPATH') or die('No direct script access.'); class Controller_Backend_Configuration extends Controller_Backend_Template { public function action_list() { $ls_configuration = ORM::factory('config_configuration')->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'); } }
  • 3. Julio Pari - CodigoAgil.com 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'); }); } }); }) } });