I need to add a js statement to onsubmit event of blockform.
I try to add something like this:
$statusEleName = $statusEle->getName();
$statusEle->customValidationCode[] = "if ( myform.{$statusEleName}.value == '' ) { myform.{$statusEleName}.value = 'all';}";
but it never rendered.
there is a new blockform class in 2.6 but it failed to render js codes too.
see in XOOPS26/class/xoopsform/blockform.php
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program 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.
*/
/**
* XOOPS Block Form
*
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @package class
* @subpackage xoopsform
* @since 2.6.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id: blockform.php 10942 2013-01-29 11:58:33Z dugris $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
/**
* Form that will output formatted as a HTML table
*
* No styles and no JavaScript to check for required fields.
*/
class XoopsBlockForm extends XoopsForm
{
public function __construct()
{
parent::__construct('', '', '');
}
/**
* @return string
*/
public function render()
{
$ret = '';
/* @var $ele XoopsFormElement */
foreach ($this->getElements() as $ele) {
if (!$ele->isHidden()) {
$ret .= "<strong>" . $ele->getCaption()."</strong>";
$ret .= " " . $ele->render() . "";
$ret .= " <i>" . $ele->getDescription() . "</i><br /><br />";
} else {
$ret .= $ele->render();
}
}
$ret .= '';
return $ret;
}
}
If i use a separate nest form inside blockform it show codes but it seems it is useless in a nested form.
see:
<script type='text/javascript'>
<!--//
function xoopsFormValidate_list_block() { var myform = window.document.list_block; if ( myform.options[0].value == '' ) { myform.options[0].value = 'all';}return true;
}
//--></script>
It seems there is no easy way to add js in a block form.


















