Hello,
I cannot get the _validateSubmission or validateSubmission methods to be called during the submission of my element still. I have read all the documentation around this and have studied similar elements (e.g. media\zoo\elements\image\image.php) and I cannot see what I am not doing that they are that prevents the methods being called.
I have created a new element in case there was something during the install that was causing the problem. I have used the documentation and examples as guides to create a simple element that provides a single file upload, I ave created many of the methods as stubs to minimise the number of complications, but it has all that is required such that validateSubmission (and therefore as it is repeatable _validateSubmission) should be called.
The new element is called certificate and the files are as follows:
media/zoo/applications/jbuniversal/elements/certificate/certificate.xml
<?xml version="1.0" encoding="utf-8" ?>
<element type="certificate" group="PlayInspectors">
<name>Certificate</name>
<author>Stuart Laverick</author>
<creationDate>23 August 2015</creationDate>
<copyright>Copyright (C) WeAreNet</copyright>
<authorEmail>info@wearenet.co.uk</authorEmail>
<authorUrl>http://www.wearenet.co.uk/</authorUrl>
<version>0.1</version>
</element>
media/zoo/applications/jbuniversal/elements/certificate/certificate.php
<?php
/**
* Element to manage uploaded certificates
*
* @package playinspectors
* @version 0.1
* @author WeAreNet http://www.wearenet.co.uk
* @copyright Copyright (C) WeAreNet, All rights reserved.
* @license http://jbzoo.com/license-pro.php JBZoo Licence
* @author Stuart Laverick
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');
/**
* Manage PDF certificates
*
* @package playinspectors
* @author Stuart Laverick
**/
class ElementCertificate extends ElementRepeatable implements iRepeatSubmittable
{
/**
* Output and editing form for each element
* @return bool | string HTML
* @author Stuart Laverick
**/
protected function _edit($params = array())
{
$this->log($params);
if ($layout = $this->getLayout('_edit.php')) {
return $this->renderLayout($layout);
}
return false;
}
/**
* Output data for each element during item submission
*
* @param array $params submission parameters
* @return bool | string HTML
* @author Stuart Laverick
**/
public function _renderSubmission($params = array())
{
$this->log($params);
return $this->_edit($params);
}
/**
* Validate input data for each element after item submission
*
* @return void
* @author Stuart Laverick
**/
public function _validateSubmission($value, $params)
{
$this->log($value);
}
/**
* Returns a dictionary of exam types based on the set Inspector Type
*
* @return Array
* @author Stuart Laverick
**/
private function getExamTypes()
{
if ($this->config->get('inspectortype', 'routine') == 'routine') {
return array (
'none' => '- None',
'operational-candidates-practical-report' => 'Operational Candidates Practical Report',
'operational-candidates-written-exam' => 'Operational Candidates Written Exam',
'operational-examiner-report-sheet' => 'Operational Examiner Report Sheet',
'operational-examiners-master-report' => 'Operational Examiners Master Report',
'operator-attendant-examiners-marking-sheet' => 'Operator /Attendant Examiners Marking Sheet',
'operator-attendant-practical-exam' => 'Operator /Attendant Practical Exam',
'operator-attendant-written-exam' => 'Operator /Attendant Written Exam',
'routine-candidates-practical-report' => 'Routine Candidates Practical Report',
'routine-examiner-report-sheet' => 'Routine Examiner Report Sheet',
'routine-examiners-master-report' => 'Routine Examiners Master Report'
);
}
return array (
'none'=>'- None',
'indoor-annual-candidates-exam-paper'=>'Indoor Annual Candidates Exam Paper',
'indoor-annual-candidates-practical-report'=>'Indoor Annual Candidates Practical Report',
'indoor-annual-examiners-marking-sheet'=>'Indoor Annual Examiners Marking Sheet',
'inflatable-annual-candidates-exam-paper'=>'Inflatable Annual Candidates Exam Paper',
'inflatable-annual-candidates-practical-report'=>'Inflatable Annual Candidates Practical Report',
'inflatable-annual-examiners-marking-sheet'=>'Inflatable Annual Examiners Marking Sheet',
'outdoor-annual-candidates-exam-paper'=>'Outdoor Annual Candidates Exam Paper',
'outdoor-annual-candidates-practical-report'=>'Outdoor Annual Candidates Practical Report',
'outdoor-annual-examiners-marking-sheet'=>'Outdoor Annual Examiners Marking Sheet'
);
}
/**
* Element specific logging
*
* @return void
* @author Stuart Laverick
**/
private function log($value, $fullTrace = false)
{
jimport('joomla.log.log');
JLog::addLogger(
array(
'text_file' => 'exam_certificate.log.php'
),
JLog::ALL,
array('exam_certificate')
);
$trace = debug_backtrace(false);
if ($fullTrace) {
$caller = array();
foreach ($trace as $call) {
$caller[] = array(
'file' => $call['file'],
'line' => $call['line'],
'class' => $call['class'],
'function' => $call['function']
);
}
} else {
$caller = isset($trace[1]['class']) ? $trace[1]['class'] . '::' . $trace[1]['function'] : $trace[1]['function'];
}
$message = is_array($value) || is_object($value) ? print_r($value, true) : $value;
$message.= "\n" . $caller;
JLog::add(JText::_($message), JLog::DEBUG, 'exam_certificate');
}
} // END class iRepeatSubmittable
media/zoo/applications/jbuniversal/elements/certificate/tmpl/_edit.php
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
?>
<div style="margin-bottom: 5px;">
<span style="float:left;width:90px;">Certificate PDF</span>
<input type="file"
id="<?php echo $this->getControlName('certificate_pdf'); ?>"
name="<?php echo $this->getControlName('certificate_pdf'); ?>"
title="<?php echo JText::_('Certificate PDF'); ?>" />
<?php if (isset($link) && $link): ?>
<a href="<?php echo $link; ?>">Certificate</a>
<?php endif; ?>
</div>
I would be grateful if you could look at this and provide any clues as to where I am going wrong. I have not implemented validateSubmission on the class as this should be available on the abstract parent ElementRepeatable and this should then call _validateSubmission, but it obviously is not.
The class as it stands is just set up with logging calls so I can observe what happens and what gets called. The method _edit is called and writes to the log, but so far none of the other logging calls are run.
If you require access to the site this can be arranged if it will help to resolve this issue. We have paid for a pro licence so are hoping for some support on this matter.
Thanks