Posted on: 2013/4/7 13:08
#4
Re: How to add a customValidationCode to xoopsFormValidate_blockform
2013/4/7 13:08
I don't think it is the final solution, but at the moment, in 2.6.0 alpha2 there is a file named modules/system/blocks/system_blocks.php
Inside there are 2 kind of specific functions b_xxx_show and b_xxx_edit. The former is for display specific content of a block and the later is for editing.
I have modified the b_system_info_edit
function b_system_info_edit($options)
{
$block_form = new XoopsBlockForm();
$block_form->addElement( new XoopsFormText(_MB_SYSTEM_PWWIDTH, 'options[0]', 1, 3, $options[0]), true);
$block_form->addElement( new XoopsFormText(_MB_SYSTEM_PWHEIGHT, 'options[1]', 1, 3, $options[1]), true);
$block_form->addElement( new XoopsFormText(sprintf(_MB_SYSTEM_LOGO, XOOPS_URL . "/images/"), 'options[2]', 5, 100, $options[2]), true);
$block_form->addElement(new XoopsFormRadioYN(_MB_SYSTEM_SADMIN, 'options[3]', $options[3]));
return $block_form->render();
}
which is the code found in main.php block
As You see we can add specific elements and with the parameter 'true' in addElement we can set Rquired to true.
Then with my modification in the render method in blockform.php. The specific fields are displayed and in the html file there are javascript scripts to check if the fields are empty and display an erreur message, in the option part of the form.
I hope this could help.