set_data() won't display the data from DB in an edit form

set_data() won't display the data from DB in an edit form

by Elisa ... -
Number of replies: 0
Hello!

We are developing a new slide module for moodle. To edit the slides we have a form which allows you to select from a list the slide you want to edit, then a "No Submit Button" should show its title and its content in a text box and a html editor.
But when we press this button the form reloads with the slide title and the slide content in blank. There is no Debug message left.
¿Does anyone have a clue about this?

Here is our code:

edit.php

if ($mform->is_cancelled()){
redirect("view.php?id=$cm->id");
} elseif ($mform->no_submit_button_pressed()) {


$fromform = $mform->get_submitted_data();

$diapositiva = get_record('autotutor_diapinf', 'autotutorid', $autotutor->id, 'orden', ($fromform->selecciona)+1);

$toform->selecciona = $fromform->selecciona;
$toform->titulo = $diapositiva->titulo;
$toform->html_slide = $diapositiva->html_slide;
$toform->id = $cm->id;

$mform->set_data($toform); //Is this doesn't listening to us?

}


edit_form.php

$selecdiap = array();
for ($j=1; $j<= $autotutor->numdiap; $j++) {
$selecdiap = array_pad($selecdiap, $j, "Diapositiva $j");
}
$mform->addElement('select', 'selecciona', get_string('choice','autotutor'), $selecdiap);

 
$mform->addElement('submit', 'mostrar', get_string('show','autotutor'));


$mform->registerNoSubmitButton('mostrar');


 
$mform->addElement('text', 'titulo', 'Título de la Diapositiva');
$mform->setType('titulo', PARAM_TEXT);

$mform->addElement('htmleditor', 'html_slide', 'Contenido de la diapositiva', array('rows'=>20));
$mform->setType('html_slide', PARAM_RAW);
$mform->setHelpButton('html_slide', array('writing', 'richtext'), false, 'editorhelpbutton');

$mform->addElement('format');

Thanks in advance.
Average of ratings: -