SlideShare une entreprise Scribd logo
1  sur  3
Télécharger pour lire hors ligne
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'); });
}
});
})
}
});

Contenu connexe

Tendances

17. CodeIgniter login simplu cu sesiuni
17. CodeIgniter login simplu cu sesiuni17. CodeIgniter login simplu cu sesiuni
17. CodeIgniter login simplu cu sesiuniRazvan Raducanu, PhD
 
Engines: Team Development on Rails (2005)
Engines: Team Development on Rails (2005)Engines: Team Development on Rails (2005)
Engines: Team Development on Rails (2005)lazyatom
 
Technical Preview: The New Shopware Admin
Technical Preview: The New Shopware AdminTechnical Preview: The New Shopware Admin
Technical Preview: The New Shopware AdminPhilipp Schuch
 
Flask 소수전공 강의자료 - 2차시
Flask 소수전공 강의자료 - 2차시Flask 소수전공 강의자료 - 2차시
Flask 소수전공 강의자료 - 2차시Junha Jang
 

Tendances (12)

17. CodeIgniter login simplu cu sesiuni
17. CodeIgniter login simplu cu sesiuni17. CodeIgniter login simplu cu sesiuni
17. CodeIgniter login simplu cu sesiuni
 
Engines: Team Development on Rails (2005)
Engines: Team Development on Rails (2005)Engines: Team Development on Rails (2005)
Engines: Team Development on Rails (2005)
 
Technical Preview: The New Shopware Admin
Technical Preview: The New Shopware AdminTechnical Preview: The New Shopware Admin
Technical Preview: The New Shopware Admin
 
Trabajo
TrabajoTrabajo
Trabajo
 
Owasp & php
Owasp & phpOwasp & php
Owasp & php
 
23. CodeIgniter sessions
23. CodeIgniter sessions23. CodeIgniter sessions
23. CodeIgniter sessions
 
Flask 소수전공 강의자료 - 2차시
Flask 소수전공 강의자료 - 2차시Flask 소수전공 강의자료 - 2차시
Flask 소수전공 강의자료 - 2차시
 
Dos
DosDos
Dos
 
Div id
Div idDiv id
Div id
 
Fcr 2
Fcr 2Fcr 2
Fcr 2
 
Convidar para page !!
Convidar para page !!Convidar para page !!
Convidar para page !!
 
Documento
DocumentoDocumento
Documento
 

En vedette

Prototyping for tiny fingers
Prototyping for tiny fingersPrototyping for tiny fingers
Prototyping for tiny fingersJulio Pari
 
Algoritmica i clase03 practica 3 solucionario
Algoritmica i clase03 practica 3 solucionarioAlgoritmica i clase03 practica 3 solucionario
Algoritmica i clase03 practica 3 solucionarioJulio Pari
 
Rettig onprototyping
Rettig onprototypingRettig onprototyping
Rettig onprototypingJulio Pari
 
Spredfast pocketguide-final
Spredfast pocketguide-finalSpredfast pocketguide-final
Spredfast pocketguide-finalJulio Pari
 
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02Julio Pari
 
Algoritmica i clase06 ejercicio apuntadores
Algoritmica i clase06 ejercicio apuntadoresAlgoritmica i clase06 ejercicio apuntadores
Algoritmica i clase06 ejercicio apuntadoresJulio Pari
 
Amazon dynamo-sosp2007
Amazon dynamo-sosp2007Amazon dynamo-sosp2007
Amazon dynamo-sosp2007Julio Pari
 
Jdeveloper 11g
Jdeveloper 11gJdeveloper 11g
Jdeveloper 11gJulio Pari
 

En vedette (8)

Prototyping for tiny fingers
Prototyping for tiny fingersPrototyping for tiny fingers
Prototyping for tiny fingers
 
Algoritmica i clase03 practica 3 solucionario
Algoritmica i clase03 practica 3 solucionarioAlgoritmica i clase03 practica 3 solucionario
Algoritmica i clase03 practica 3 solucionario
 
Rettig onprototyping
Rettig onprototypingRettig onprototyping
Rettig onprototyping
 
Spredfast pocketguide-final
Spredfast pocketguide-finalSpredfast pocketguide-final
Spredfast pocketguide-final
 
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
 
Algoritmica i clase06 ejercicio apuntadores
Algoritmica i clase06 ejercicio apuntadoresAlgoritmica i clase06 ejercicio apuntadores
Algoritmica i clase06 ejercicio apuntadores
 
Amazon dynamo-sosp2007
Amazon dynamo-sosp2007Amazon dynamo-sosp2007
Amazon dynamo-sosp2007
 
Jdeveloper 11g
Jdeveloper 11gJdeveloper 11g
Jdeveloper 11g
 

Similaire à Kohana bootstrap - modal form

Make More Money With Advanced Custom Fields - WordCampYYC 2015
Make More Money With Advanced Custom Fields - WordCampYYC 2015Make More Money With Advanced Custom Fields - WordCampYYC 2015
Make More Money With Advanced Custom Fields - WordCampYYC 2015buildstudio
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIOliver Häger
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckAnthony Montalbano
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Daniel Downs
 
Slimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksSlimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksThemePartner
 
Clever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksClever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksThemePartner
 
Copy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazaCopy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazahelgawerth
 
The project gutenberg e book, fairy tales from brazil, by elsie spicer
The project gutenberg e book, fairy tales from brazil, by elsie spicerThe project gutenberg e book, fairy tales from brazil, by elsie spicer
The project gutenberg e book, fairy tales from brazil, by elsie spicerAndrei Hortúa
 
Vue.js - zastosowanie i budowa komponentów
Vue.js - zastosowanie i budowa komponentówVue.js - zastosowanie i budowa komponentów
Vue.js - zastosowanie i budowa komponentówLaravel Poland MeetUp
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2RORLAB
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2James Pearce
 
Improving state of M2 front-end - Magento 2 Community Project
Improving state of M2 front-end - Magento 2 Community ProjectImproving state of M2 front-end - Magento 2 Community Project
Improving state of M2 front-end - Magento 2 Community ProjectBartek Igielski
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5성일 한
 
Bootstrap day4
Bootstrap day4Bootstrap day4
Bootstrap day4Shais. Net
 
07 Php Mysql Update Delete
07 Php Mysql Update Delete07 Php Mysql Update Delete
07 Php Mysql Update DeleteGeshan Manandhar
 
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!Coulawrence
 
Facebook.html
Facebook.htmlFacebook.html
Facebook.htmladmin999
 
zynga-online.facebook.html
zynga-online.facebook.htmlzynga-online.facebook.html
zynga-online.facebook.htmladmin999
 

Similaire à Kohana bootstrap - modal form (20)

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

Plus de Julio Pari

Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...Julio Pari
 
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en KubernetesLinks kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en KubernetesJulio Pari
 
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en KubernetesComandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en KubernetesJulio Pari
 
Indice General Tesis Sistemas UPC
Indice General Tesis Sistemas UPCIndice General Tesis Sistemas UPC
Indice General Tesis Sistemas UPCJulio Pari
 
Arquitectura Web FISI UNMSM
Arquitectura Web FISI UNMSMArquitectura Web FISI UNMSM
Arquitectura Web FISI UNMSMJulio Pari
 
Jelastic Enterprise
Jelastic EnterpriseJelastic Enterprise
Jelastic EnterpriseJulio Pari
 
Marketing Examen Parcial Profesor Osorio
Marketing Examen Parcial Profesor OsorioMarketing Examen Parcial Profesor Osorio
Marketing Examen Parcial Profesor OsorioJulio Pari
 
Ingenieria Software Examen Parcial 2013 2 Profesor Cordero
Ingenieria Software Examen Parcial 2013 2 Profesor CorderoIngenieria Software Examen Parcial 2013 2 Profesor Cordero
Ingenieria Software Examen Parcial 2013 2 Profesor CorderoJulio Pari
 
Documento de Arquitectura
Documento de ArquitecturaDocumento de Arquitectura
Documento de ArquitecturaJulio Pari
 
Solucion Examen Parcial Sistemas Digitales UNMSM FISI
Solucion Examen Parcial Sistemas Digitales UNMSM FISISolucion Examen Parcial Sistemas Digitales UNMSM FISI
Solucion Examen Parcial Sistemas Digitales UNMSM FISIJulio Pari
 
Práctica de Inventarios - Investigación Operativa II
Práctica de Inventarios - Investigación Operativa IIPráctica de Inventarios - Investigación Operativa II
Práctica de Inventarios - Investigación Operativa IIJulio Pari
 
Armas silenciosas para guerras tranquilas
Armas silenciosas para guerras tranquilasArmas silenciosas para guerras tranquilas
Armas silenciosas para guerras tranquilasJulio Pari
 
Formato de presentación de Proyecto UNMSM FISI
Formato de presentación de Proyecto UNMSM FISIFormato de presentación de Proyecto UNMSM FISI
Formato de presentación de Proyecto UNMSM FISIJulio Pari
 
Cuento para nuestro hijo y nuestra hija
Cuento para nuestro hijo y nuestra hijaCuento para nuestro hijo y nuestra hija
Cuento para nuestro hijo y nuestra hijaJulio Pari
 
Ingeniería de Software Examen Parcial
Ingeniería de Software Examen ParcialIngeniería de Software Examen Parcial
Ingeniería de Software Examen ParcialJulio Pari
 
Sistemas Distribuidos Examen Parcial
Sistemas Distribuidos Examen ParcialSistemas Distribuidos Examen Parcial
Sistemas Distribuidos Examen ParcialJulio Pari
 
Php07 consultas bd
Php07 consultas bdPhp07 consultas bd
Php07 consultas bdJulio Pari
 
Php06 instalacion my_sql
Php06 instalacion my_sqlPhp06 instalacion my_sql
Php06 instalacion my_sqlJulio Pari
 
Php05 funciones usuario
Php05 funciones usuarioPhp05 funciones usuario
Php05 funciones usuarioJulio Pari
 

Plus de Julio Pari (20)

Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes #Ibm virtual la...
 
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en KubernetesLinks kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Links kubernetes - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
 
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en KubernetesComandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
Comandos - Evento - Virtual Lab Despliegue de aplicaciones en Kubernetes
 
Indice General Tesis Sistemas UPC
Indice General Tesis Sistemas UPCIndice General Tesis Sistemas UPC
Indice General Tesis Sistemas UPC
 
Arquitectura Web FISI UNMSM
Arquitectura Web FISI UNMSMArquitectura Web FISI UNMSM
Arquitectura Web FISI UNMSM
 
Jelastic Enterprise
Jelastic EnterpriseJelastic Enterprise
Jelastic Enterprise
 
Marketing Examen Parcial Profesor Osorio
Marketing Examen Parcial Profesor OsorioMarketing Examen Parcial Profesor Osorio
Marketing Examen Parcial Profesor Osorio
 
Ingenieria Software Examen Parcial 2013 2 Profesor Cordero
Ingenieria Software Examen Parcial 2013 2 Profesor CorderoIngenieria Software Examen Parcial 2013 2 Profesor Cordero
Ingenieria Software Examen Parcial 2013 2 Profesor Cordero
 
Documento de Arquitectura
Documento de ArquitecturaDocumento de Arquitectura
Documento de Arquitectura
 
Solucion Examen Parcial Sistemas Digitales UNMSM FISI
Solucion Examen Parcial Sistemas Digitales UNMSM FISISolucion Examen Parcial Sistemas Digitales UNMSM FISI
Solucion Examen Parcial Sistemas Digitales UNMSM FISI
 
Práctica de Inventarios - Investigación Operativa II
Práctica de Inventarios - Investigación Operativa IIPráctica de Inventarios - Investigación Operativa II
Práctica de Inventarios - Investigación Operativa II
 
Armas silenciosas para guerras tranquilas
Armas silenciosas para guerras tranquilasArmas silenciosas para guerras tranquilas
Armas silenciosas para guerras tranquilas
 
UML Java
UML JavaUML Java
UML Java
 
Formato de presentación de Proyecto UNMSM FISI
Formato de presentación de Proyecto UNMSM FISIFormato de presentación de Proyecto UNMSM FISI
Formato de presentación de Proyecto UNMSM FISI
 
Cuento para nuestro hijo y nuestra hija
Cuento para nuestro hijo y nuestra hijaCuento para nuestro hijo y nuestra hija
Cuento para nuestro hijo y nuestra hija
 
Ingeniería de Software Examen Parcial
Ingeniería de Software Examen ParcialIngeniería de Software Examen Parcial
Ingeniería de Software Examen Parcial
 
Sistemas Distribuidos Examen Parcial
Sistemas Distribuidos Examen ParcialSistemas Distribuidos Examen Parcial
Sistemas Distribuidos Examen Parcial
 
Php07 consultas bd
Php07 consultas bdPhp07 consultas bd
Php07 consultas bd
 
Php06 instalacion my_sql
Php06 instalacion my_sqlPhp06 instalacion my_sql
Php06 instalacion my_sql
 
Php05 funciones usuario
Php05 funciones usuarioPhp05 funciones usuario
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'); }); } }); }) } });