Welcome Guest, Not a member yet? Register   Sign In
Load Default
#1

[eluser]Carlos Tafur[/eluser]
Hi,

I want to know how can do this:

I have a form, that load a information in combobox... I need that this information loads automatilly when i submited the form and generate a error that not valid empty fields


Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Registro extends CI_Controller {
    
    public function index()
    {
        $data['title']= "Registro de Pacientes - HealthCare";
        $data['pagina'] = "/registro_paciente/registro_paciente";
        $data['fecha']= date("Y-m-d");
        
        // THIS CODE I NEED LOAD AUTOMATICALLY

        
        $this->load->model('registro_paciente/Registro_model');
        $clinicas = $this->Registro_model->obtener_clinicas( );
        
        $data['clinicas'] = $clinicas;

        $this->load->view('template', $data);
    }
    
    public function nuevo()
    {
        $data['title']= "Registro de Pacientes - HealthCare";

        $this->load->library('form_validation');        
    $this->form_validation->set_rules('nombre', 'Nombre', 'required');
    $this->form_validation->set_rules('apellidos', 'Apellidos', 'required');

    if ($this->form_validation->run() == FALSE)
    {
            $data['pagina'] = "/registro_paciente/registro_paciente";
    }
    else
    {
            $data['nombre'] = $this->input->post('nombre');
            $data['apellidos'] = $this->input->post('apellidos');
            $data['pagina'] = "/registro_paciente/nuevo_paciente";
            
            $this->load->model('registro_paciente/Registro_model');
            $guardar = $this->Registro_model->guardar_datos( );
        }
        
        // THIS CODE I NEED LOAD AUTOMATICALLY
        $this->load->model('registro_paciente/Registro_model');
        $clinicas = $this->Registro_model->obtener_clinicas( );
        
        $data['clinicas'] = $clinicas;
        
        $this->load->view('template', $data);
    }
    

}
?>


I hope you understand me :-)
#2

[eluser]vitoco[/eluser]
what you need is a HOOK

http://ellislab.com/codeigniter/user-gui...hooks.html

More specifically, the "display_override" Hook :

Code:
display_override
Overrides the _display() function, used to send the finalized page to the web browser at the end of system execution. This permits you to use your own display methodology. Note that you will need to reference the CI superobject with $this->CI =& get_instance() and then the finalized data will be available by calling $this->CI->output->get_output()

of course, the hook runs on every load of the system, so if you wanna do the "AUTOMATICALLY" part only for that controller, you must condition it by url

Saludos
#3

[eluser]danmontgomery[/eluser]
Uh... or just use set_value()
#4

[eluser]Carlos Tafur[/eluser]
[quote author="vitoco" date="1307963497"]what you need is a HOOK

http://ellislab.com/codeigniter/user-gui...hooks.html

More specifically, the "display_override" Hook :

Code:
display_override
Overrides the _display() function, used to send the finalized page to the web browser at the end of system execution. This permits you to use your own display methodology. Note that you will need to reference the CI superobject with $this->CI =& get_instance() and then the finalized data will be available by calling $this->CI->output->get_output()

of course, the hook runs on every load of the system, so if you wanna do the "AUTOMATICALLY" part only for that controller, you must condition it by url

Saludos[/quote]

A example!
#5

[eluser]Carlos Tafur[/eluser]
[quote author="noctrum" date="1307985136"]Uh... or just use set_value()[/quote]

No because I need, that the select in the form charged after if generated error.
#6

[eluser]vitoco[/eluser]
Search "display_override" in the forums, there's an example of this.
#7

[eluser]danmontgomery[/eluser]
[quote author="Carlos Tafur" date="1308002297"][quote author="noctrum" date="1307985136"]Uh... or just use set_value()[/quote]

No because I need, that the select in the form charged after if generated error.[/quote]

Code:
<?php echo form_dropdown('field_name', $field_options, set_value('field_name')); ?>

Will give you a select field named "field_name", with the options $field_options, and if the form has been posted (form validation failed) the default value will be whatever was selected
#8

[eluser]Carlos Tafur[/eluser]
thanks!

Last question, a app with login user and permissions per page, where I found?
#9

[eluser]Carlos Tafur[/eluser]
[quote author="noctrum" date="1308009712"][quote author="Carlos Tafur" date="1308002297"][quote author="noctrum" date="1307985136"]Uh... or just use set_value()[/quote]

No because I need, that the select in the form charged after if generated error.[/quote]

Code:
<?php echo form_dropdown('field_name', $field_options, set_value('field_name')); ?>

Will give you a select field named "field_name", with the options $field_options, and if the form has been posted (form validation failed) the default value will be whatever was selected[/quote]


Last question, a app with login user and permissions per page, where I found?




Theme © iAndrew 2016 - Forum software by © MyBB