atk4

Why can't add js() to a dropdown field on a form?


I just keep getting this error: Method js is not defined neither in controller, nor in its Model.

Thi is my page

class page_alumnos_inscribir extends Page {
function init(){
    parent::init();
    $page=$this;
    $model=$this->add('Model_Alumno')->loadData($_GET['id']);

    $h=$this->add('H3')->set($model->get('name').' ( '.$model->get('grado').$model->get('nivel'). ' )');

    $f=$page->add('Form');
    $r=$f->addField('dropdown','Inscribir al Curso')->setModel('Curso');
    $r->js('change')->univ()->alert('orale');

    $s=$f->addField('line','montoPeriodo');   
}

}


Solution

  • You wrote a wrong chain. Set model returns the added model, you need the created field instead. Try to do it in this way:

    $r=$f->addField('dropdown','Inscribir al Curso');
    $r->setModel('Curso');
    $r->js('change')->univ()->alert('orale');