Yii Framework Forum: Ajax Validation From Form Within Widget - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Validation From Form Within Widget Rate Topic: -----

#1 User is offline   Yoggsoft 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-October 12
  • Location:Buenos Aires

Posted 19 March 2013 - 01:47 PM

Hey guys, im having a bad time here with widgets loaded through Ajax and it's validation... as you can see.. im loading a widget from ajaxButton

        'data':{'fecha':fechaActual,'month':<?php echo $this->month ?>,'year':<?php echo $this->year ?>},
        'url':'...?r=evento/createNuevoEvento', <- path was shorcut intentionally for this post
            $("#newEvento").html(html)} <-area where it loads the widget
    return false;

the controller "createNuevoEvento only renderpartials a _view and this _view only instantiates the widget...

            $form=$this->beginWidget('CActiveForm', array(
                'id' => 'evento-form',
                'enableClientValidation' => true,
            ?> <-only declaration parameters obviously

public function run()
        $usuario = Usuario::model()->getUsuarioSession();
        $fecha = $this->year.'-'.$this->month.'-'.$this->fecha;
        if(isset($_POST['ajax']) && $_POST['ajax']==='evento-form')
                        echo CActiveForm::validate($this->model);
            echo CActiveForm::validate( array($model));
        } */
            // collects user input data
            // validates user input and redirect to previous page if validated
            if($this->model->validate()) {
                $this->model->COMISION_idCOMISION = 9;
                $this->model->USUARIO_owner = $usuario->id;
                $fechaHoy = date('Y-m-d H:i:s');
                $this->model->fechacreacion = $fechaHoy;
                $this->model->fechahoraDelEvento = $fechaHoy;
                //$model->fechacreacion = new DbExpression("NOW()");
                $this->model->fueNotificado = 1;
                //$model->fechahoraDelEvento = new DbExpression("NOW()");
                $this->model->estado = 0;
                //$this->render("_listaDia",array('arrayEventosPosibles' => $this->tiposEvento));
        // displays the form
            'model' => $this->model,
            'arrayEventosPosibles' => $this->tiposEvento,
            'fecha'=> $fecha));

thing is: when instantiating the widget on any other view, works good... but when instantiating the widget inside the ajax-loaded view, doesn't validate fields on change, and when submitting, switches to another view.... what am i doing wrong? any other approach i could face to... im a Yii and AJAX kinda newbie..

thx in advantage...

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users