Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
6 - 4 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
   

Re: How to add a customValidationCode to xoopsFormValidate_blockform
by irmtfan on 2013/4/9 2:27:59

I tried a lot. none of the solution will work because the main issue is it create a nested form.
The only solution is finding a way to get the $form element and add new element to this $form
Re: How to add a customValidationCode to xoopsFormValidate_blockform
by alain91 on 2013/4/8 18:30:02

You are right, there is not way at the moment to get the name of the Form.

But, there is a convention, and the name of the form is 'blockform'

So, just pass this name
le="color: #000000"><?php class XoopsBlockForm extends XoopsForm { public function __construct() { parent::__construct('', 'blockform', ''); }


The red stars :

This works with xhtml but now xoops use HTML5. And html5 have new tags and attributs. One new attribut is named 'required'. using 'required' in an input tag automatically check if the field is empty and display a message in case of error. No javascript in needed.

After few tests, I found the 'required' attribute in input tag ignores the script in javascript. I will continue to investigate.

One could try to use addEelement with false for required parameter.

Re: How to add a customValidationCode to xoopsFormValidate_blockform
by irmtfan on 2013/4/8 6:01:53

see this picture
http://www.xoops.ir/uploads/newbb/15_51625bdce4886.jpg

the bigger red star is jQuery (which i dont know what is the function)

the smaller red star is xoopsform (xoopsFormValidate_blockform) which didnt work in options as you can see.

I hope somebody could find a solution for this.
Re: How to add a customValidationCode to xoopsFormValidate_blockform
by irmtfan on 2013/4/8 4:38:02

Sorry my bad.
I didnt test "is required" in 2.6 because my main problem was adding some js codes as customValidationCode.

Now i see you are right and required is working in 2.6
I still cannot find why it is working in 2.6 but not in 2.5.5
for example see publisher
In 2.6 "is required" in publisher blocks worked
In 2.5.5 publisher module by using the same form for blocks "is required" is not working.

but it is not important for me.
the main bug still remain.
adding a customValidationCode to xoopsFormValidate_blockform is not possible.
try to change your code by this:
le="color: #000000"><?php function b_system_info_edit($options) { $block_form = new XoopsBlockForm(); $dispEle = new XoopsFormText(SystemLocale::POPUP_WINDOW_WIDTH, 'options[0]', 1, 3, $options[0]); $dispEle->customValidationCode[]="alert('this is a test');"; $block_form->addElement($dispEle , true); $block_form->addElement( new XoopsFormText(SystemLocale::POPUP_WINDOW_HEIGHT, 'options[1]', 1, 3, $options[1]), true); $block_form->addElement( new XoopsFormText(sprintf(SystemLocale::F_LOGO_IMAGE_FILE_IS_LOCATED_UNDER, XOOPS_URL . "/images/"), 'options[2]', 5, 100, $options[2]), true); $block_form->addElement(new XoopsFormRadioYN(SystemLocale::SHOW_ADMIN_GROUPS, 'options[3]', $options[3])); return $block_form->render(); }


js codes will not add to function xoopsFormValidate_blockform()

edit:
search function xoopsFormValidate in the source code page and you can see these codes will be added to
function xoopsFormValidate_() which is the main bug because this is the nested form.(another form inside the blockform)
I hope you understand me.
Re: How to add a customValidationCode to xoopsFormValidate_blockform
by alain91 on 2013/4/7 13:08:23

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

le="color: #000000"><?php 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.

Who's Online

331 user(s) are online (272 user(s) are browsing Support Forums)


Members: 0


Guests: 331


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits