Xavier:
Logré encontrar un ejemplo de como hacer un botón popUp, pero lamentablemente no logro hacerlo funcionar como corresponde, te adjunto el código de mi archivo mod_form para ver si por favor me puedes ayudar en esto, ya que me tiene de verdad muy acomplejado.
Destaqué en amarillo la parte donde se genera el botón
ojalá puedas ayudarme
Saludos
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The main mensajes configuration form
*
* It uses the standard core Moodle formslib. For more info about them, please
* visit: http://docs.moodle.org/en/Development:lib/formslib.php
*
* @package mod_mensajes
* @copyright 2010 Your Name
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/course/moodleform_mod.php');
class mod_mensajes_mod_form extends moodleform_mod {
function definition() {
global $COURSE;
$mform =& $this->_form;
//-------------------------------------------------------------------------------
/// Adding the "general" fieldset, where all the common settings are showed
$mform->addElement('header', 'general', get_string('general', 'form'));
/// Adding the standard "name" field
$mform->addElement('text', 'name', get_string('mensajesname', 'mensajes'), array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEAN);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addHelpButton('name', 'mensajesname', 'mensajes');
//-------------------------------------------------------------------------------
/// Adding the rest of mensajes settings, spreeading all them into this fieldset
/// or adding more fieldsets ('header' elements) if needed for better logic
$mform->addElement('text', 'teacher_message', get_string('mensajesteacher','mensajes'),array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('teacher_message', PARAM_TEXT);
} else {
$mform->setType('teacher_message', PARAM_CLEAN);
}
$mform->addRule('teacher_message', null, 'required', null, 'client');
$mform->addRule('teacher_message', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addHelpButton('teacher_message', 'mensajesteacher', 'mensajes');
$mform->addElement('text', 'student_message', get_string('mensajesstudent','mensajes'),array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('student_message', PARAM_TEXT);
} else {
$mform->setType('student_message', PARAM_CLEAN);
}
$mform->addRule('student_message', null, 'required', null, 'client');
$mform->addRule('student_message', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addHelpButton('student_message', 'mensajesstudent', 'mensajes');
$choosefile_button = $mform->createElement('button', 'popup', 'Probando un popup');
// create a 'reference' group of form elements, comprising text box + buttons
$elements = array();
$elements[] = $mform->createElement('text', 'reference', '', array('size'=>'60'));
$elements[] = &$choosefile_button;
$mform->addGroup($elements, 'reference_elements', 'prueba', ' ' , false);
// set attributes on the button
if ($choosefile_button) {
$url="formularios/formularios.php";
$options = 'menubar=0,location=0,scrollbars,resizable,width=750,height=500';
$attributes = array(
'title'=>'prueba de formularios',
'onclick'=>"return openpopup('".$url."', '".$choosefile_button->getName()."', '".$options."', 0);"
);
$choosefile_button->updateAttributes($attributes);
}
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// add standard buttons, common to all modules
$this->add_action_buttons();
}
}