Custom Select [GH] action crash - parse error

NickOg 29 Apr, 2012
Hi Bob,

I have just begun using your excellent plug in. I installed one control (to generate a range of weeks numbers) and it worked fine. I added another to read a set of options from a new options file and I have received this error message

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in W:\Ampps\www\pmhu3a\administrator\components\com_chronoforms\form_actions\show_html\cfaction_show_html.php(136) : eval()'d code on line 96



I can't be sure it is generated because I added that second event or because I set up a new options file. The problem is now that even removing that second event and its control it crashes consistently with this error unless I turn that dynamic option off in the remaining control.

Any idea what I have done wrong?

Regards

Nick
GreyHead 29 Apr, 2012
Hi Nick,

The error appears to be showing up on line 96 of the Form HTML. Is there anything obvious if you look in the Form code tab?

If not, please send me a copy of the optiosn file you created and I'll test it here to see if I get the same result.

Bob
NickOg 29 Apr, 2012
Hi Bob,

I have stripped everything except one #RANGE# option from the form (see attached) ad I am still getting the same problem. There is a syntax error in the form code, it seems.

<div class="ccms_form_element cfdiv_checkboxgroup" id="idchkwhichweeks_container_div"><label for="idchkWhichWeeks">Which Weeks</label><input type="hidden" name="chkWhichWeeks" value="" alt="ghost" />
<div style="float:left; clear:none;">
						<?php
						$options_data = $form->get_array_value($form->data, explode(".", "mdlWhichWeeks"));
						if(!is_null($options_data) && is_array($options_data)){
							$f_id = 0;
							foreach($options_data as $option_data){
								if(isset($option_data["value"]) && isset($option_data["text"])){
									echo '<input type="checkbox" name="chkWhichWeeks[]" id="chkwhichweeks_'.$f_id.'" title="" value="'.$option_data["value"].'"'.(in_array($option_data["value"], array (
  0 => '',
)) ? ' checked="checked"' : '').' class="validate['group[16]']" />'."\n";
									echo '<label for="chkwhichweeks_'.$f_id.'">'.$option_data["text"].'</label>'."\n";
									$f_id++;
								}
							}
						}
						?>
						</div><div class="clear"></div><div id="error-message-chkWhichWeeks"></div></div>


I have started a form from scratch and added a #RANGE# and an options file (one of yours)and an edit of one of yours to suit my needs. That seems to work fine. I will go on and reconstruct the original form and see how far I get. I have retained the form attached in case you can point me to an error

Regards

Nick
NickOg 29 Apr, 2012
Eureka! I have just found the cause of the crash. If you switch validation on, it crashes. Switch it off and all is well.

Nick
GreyHead 30 Apr, 2012
Hi Nick,

Your diagnosis is spot on :-(

It looks like the RePublisher is getting indigestion when it tries to add the 'checked' option to a selected checkbox. Not too surprising as the tag is already embedded into a PHP echo statement :-(

I think that this is quite a deep bug in the RePublisher/Dynamic Data code rather than a particular problem with the Custom Select [GH] action.

Bob

This code (line breaks changed):
echo '<input type="checkbox" name="chkWhichWeeks[]" id="chkwhichweeks_'.$f_id.'" title="" value="'.$option_data["value"].'" 
'.(in_array($option_data["value"], array ( 0 => '',) ) ? ' checked="checked"' : '').' class="validate['group[16]']" />'."\n";
is where the problem is.
NickOg 30 Apr, 2012

It looks like the RePublisher is getting indigestion when it tries to add the 'checked' option to a selected checkbox. Not too surprising as the tag is already embedded into a PHP echo statement :-(

I think that this is quite a deep bug in the RePublisher/Dynamic Data code rather than a particular problem with the Custom Select [GH] action.



And is that part of Chronoforms or Joomla?

Nick
GreyHead 30 Apr, 2012
Hi Nick,

I found the fix for this and will post it here and then add a link to the CF bugs list.

In administrator/components/com_chronoforms/helpers/html_helper.php look for this line around line 438. This is the fixed version:
echo \'<input type="'.$fieldoptions['type'].'" name="'.$fieldname.'[]" id="'.$this->slug($fieldname.'-').'\'.$f_id.\'" title="'.$tag['title'].'" value="\'.$option_data["'.$tag["value_key"].'"].\'"\'.((in_array($option_data["'.$tag["value_key"].'"], '.var_export($checked, true).')) ? \' checked="checked"\' : \'\').\' class="'.addslashes($tag['class']).'" />\'."\n";

There are:[list]
  • extra () around
    (in_array($option_data["'.$tag["value_key"].'"], '.var_export($checked, true).'))


  • and addslashes() in
    class="'.addslashes($tag['class'])
  • [/list]
    Bob
    NickOg 08 May, 2012
    Hi Bob,

    I suspect that this problem goes deeper. It isn't just validation that seems to cause the crash.

    Without a record loader it works fine.
    With an 'un-configured' record loader - that is no db table referenced it works fine.
    With a db table defined again it works fine
    Add a db field and it crashes
    <select id="ididLocation" class="" name="idLocation" title="" size="1"> Fatal error: Call to a member function get_array_value() on a non-object in W:\Ampps\www\pmhu3a\components\com_chronoforms\libraries\includes\data_republish.php(24) : eval()'d code on line 4 </select>


    If I do the same thing with a multi record loader it works OK with it not configured or configured. It seems to be something to do with the db record loader. The db record loader form called from a record list (as per the tutorials) works fine without that dynamic capability selected.
    I have attached the form that I have been trying this on - nothing to it as you can see.

    I am using 4.0 RC3.3 and had better go see if there is a later one.

    ps = I forgot to add that I applied that fix that you posted and that didn't help this situation.

    Regards

    Nick
    Max_admin 09 May, 2012
    Hi Nick,

    Yes, I found a bug in this section recently and fixed it, please contact me through the "Contact Us" page and I will send you the fixed file.

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    GreyHead 15 May, 2012
    Hi,

    Just checking. Was this a bug in the Custom Select [GH] action or the DB Record Loader?

    Bob
    NickOg 16 May, 2012
    Hi Bob,
    I have your custom select working OK but not the db loader version. I should add that I have passed some info back to Max and I hope to have it sorted shortly. it could be something that I have done wrong but I can't see what!

    Nick
    This topic is locked and no more replies can be posted.