Forums | Mahara Community

Developers /
Databases


Osbel Rondón's profile picture
Posts: 23

16 March 2017, 17:03

Hello everyone
I'm developing a mahara customization and I'm creating a plugin that adds menu items with forms on the pages. However the data I enter in the forms is not saved in the database. Someone knows what to solve that. Please, I need ideas.
Thanks in advance.

Kevin Rickis's profile picture
Posts: 67

16 March 2017, 22:18

Hi Osbel,

The submit function of ArtefactTypePlan in artefact/plans/lib.php is a good example of this. It also has an example of a  validate function if you require validation of your forms.

 

Kevin

 

Osbel Rondón's profile picture
Posts: 23

17 March 2017, 10:40

Thanks for answering me, Kevin.
I was looking at the example you told me and I made a group of modifications to insert into the database but I still get the same error.

Site unavailable: A nonrecoverable error ocurred. This probably means you have encountered a bug in the system

If you can take a look at the submit function that I have implemented and tell me if something wrong.

function personalform_submit(Pieform $form, $values) {
    global $SESSION;
    global $USER;
    global $personalfields;

    $personalfields = array(
        'artefact'   => $USER->get('id'),
        'uno'        => $values['uno'],
        'dos'        => $values['dos'],    
    );

    db_begin();
    insert_record('artefact_deduko_personal', $personalfields);

    db_commit();

    $SESSION->add_ok_msg(get_string('personalinformationsaved','artefact.deduko'));
    
}

Thank you

Kevin Rickis's profile picture
Posts: 67

17 March 2017, 11:58

Hi Osbel,

I can't see anything obviously wrong with your submit function but you really need to see an error message. 

Assuming you are hosting on Apache, add the following to .htaccess in your hosting directory, you may need to create this the .htacess file.

php_flag display_errors on

Also add the lines below to the config.php.

$cfg->log_dbg_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_info_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_warn_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_environ_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;

You should then see all error messages and warnings.

There is useful debugging info here.

4 results