Javascript error when I hide fields from module

  • Jonathan Dagenais
  • Jonathan Dagenais's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 5 months ago #1 by Jonathan Dagenais
Javascript error when I hide fields from module was created by Jonathan Dagenais
Hi,

Sorry for my bad english.

I had a Javascript error when I try to hide fields (name and antispam) from module.
It seems related to the javascript function nspro_parseErrors(response){ }.
On the source code iIt seems to always check for these fields.
var field_array = [ "name", "email", "as_answer" ];

Thanks for your great component.

Please Log in or Create an account to join the conversation.

  • Christopher Mavros
  • Christopher Mavros's Avatar
  • Offline
  • Administrator
  • Administrator
More
10 years 5 months ago #2 by Christopher Mavros
Replied by Christopher Mavros on topic Javascript error when I hide fields from module
Hello Jonathan.
Thank you for posting.

How did you try to hide the name and anti spam fields?

Thanks again.

Christopher Mavros
me@mavxr.com
If you like our extensions, please rate us on the JED!

Please Log in or Create an account to join the conversation.

  • Jonathan Dagenais
  • Jonathan Dagenais's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 5 months ago - 10 years 5 months ago #3 by Jonathan Dagenais
Replied by Jonathan Dagenais on topic Javascript error when I hide fields from module
Thanks for your quick answer.

I try to hide the fields from the module configuration screen. In the basic tab, I select to hide the name and anti-spam field.

I attached the screenshot of the configuration screen.

This image is hidden for guests.
Please log in or register to see it.
Last edit: 10 years 5 months ago by Jonathan Dagenais. Reason: Change the size of the example picture

Please Log in or Create an account to join the conversation.

  • Jonathan Dagenais
  • Jonathan Dagenais's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 5 months ago #4 by Jonathan Dagenais
Replied by Jonathan Dagenais on topic Javascript error when I hide fields from module
I forgot to mention, I get the javascript error, when I didn't fill any field and I hit the submit button.

Please Log in or Create an account to join the conversation.

  • Christopher Mavros
  • Christopher Mavros's Avatar
  • Offline
  • Administrator
  • Administrator
More
10 years 5 months ago #5 by Christopher Mavros
Replied by Christopher Mavros on topic Javascript error when I hide fields from module
You are right. This is a bug.
I fixed it and committed the update. It should be available for download online within the next 3 hours.
If you want the fix immediately, feel free to email me and I can send it to you via email.

Thanks again.

Christopher Mavros
me@mavxr.com
If you like our extensions, please rate us on the JED!
The following user(s) said Thank You: Jonathan Dagenais

Please Log in or Create an account to join the conversation.

  • Jonathan Dagenais
  • Jonathan Dagenais's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 5 months ago - 10 years 5 months ago #6 by Jonathan Dagenais
Replied by Jonathan Dagenais on topic Javascript error when I hide fields from module
Sorry, I got an other error. When I add a custom required checkbox, the script give me the same error. But I found there is no given id to the checkbox. It's a logical thing because there can be multiple checkbox with the same name.

Maybe, it can be easier to add the error class to the div containing the fields instead of given class directly on field.

I made some change on these files :
/administrator/components/com_nspro/lib.php

function PrintExtraFieldsInForm($beforeOrAfter, $field_list, $fixed_fields, $name_prefix, $sfx = '', $unique_id = '') {
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM `#__nspro_fields` WHERE `published` = 1 ORDER BY `ordering` ASC');
$afields = $db->loadObjectList();

foreach($afields as $afield) {
if ( (($beforeOrAfter == 'before') && (!$afield->abovepos)) // we want before, but field is not abovepos
|| (($beforeOrAfter == 'after') && ($afield->abovepos)) ){ // or we want after, but field is abovepos
continue;
}
if ($field_list == '1') {
$fieldarray = explode(',', $fixed_fields);
if (!in_array($afield->id, $fieldarray)) {
continue;
}
}
if ($afield->fieldtype != '7') {
$js_uid = str_replace(' ', '_', $unique_id).'_';

print '<div class="nspro_field" id="nspro_'.$js_uid.'field'.$afield->id.'_grp">';
if ($afield->name != '') {
print '<span class="nspro_field_label">'.JText::_($afield->name).'</span>';
}
}
print '<div class="nspro_custom_field_input_wrapper">'.GetFieldInputModulePlugin($afield, $sfx, $name_prefix, $unique_id).'</div>';
if ($afield->fieldtype != '7') {
print '</div>';
}
}
}


I also attached my modified /components/com_nspro/views/nspro/tmpl/default.php
This attachment is hidden for guests.
Please log in or register to see it.



Thanks for your great support
Last edit: 10 years 5 months ago by Jonathan Dagenais. Reason: Add default.php pdf file

Please Log in or Create an account to join the conversation.

Moderators: Christopher Mavros