Oliver said:
anything can be coded, but it'd have to be custom code in the corms core – and I certainly wouldn't consider this a core feature as it would work against the nature of check boxes, which are inherently optional.
just like radio buttons of which one (in a group) is required, with a preselected first button.
Hi, I'm facing similar problem (though I agree with Oliver's point of view that check boxes are inherently optional). The scenario is that we are offering lets say 4 services to a user, namely Service A, B, C and D. User must select at least one service to move on to next step. They can select more than one service, so it rules out use of radio buttons and multi-drop-down box is some what non user friendly (pressing CTRL and then selecting).
I'm able to figure out making check box group required (in non ajax mode only), but have hit another road block:
How to pass values of these check boxes (i.e. which one were selected) to subsequent steps of multi step form?
Ideally, user will select all 4 check boxes (A, B, C & D) and this would be the flow of forms:
Main form (with options) >> Form A >> Form B >> Form C >> Form D >> Thank You.
But if user selects only B & D, then flow will be:
Main form (with options) >> Form B >> Form D >> Thank You.
Another scenario: User selects A, B & C, then flow will be:
Main form (with options) >> Form A >> Form B >> Form C >> Thank You.
(You can guess all other permutations or combinations)
I'm able to access Main form's data in second step using $cformsdata Like:
if $cformsdata['data']['services']="A,B,C" then go to Form A
if $cformsdata['data']['services']="C,D" then go to Form C
But $cformsdata['data']['services'] gets lost when I go to third step (which is perfectly fine as if $cformsdata['data'] will now hold data from second step).
Now how to get data user entered in Step 1 (i,e main form) in step 3 or step 4 or step n??
This page sheds some light: http://www.delicious…..variables/
But how do I use {cf_form_Service} in Step 3/4/n using my-functions.php's function:
function my_cforms_logic($cformsdata,$oldvalue,$setting)
I need to dynamically generate next steps of form depending upon what user selected in first form. Passing "Service" field in each step (as hidden data) seems to be an option, but passing it down to 50+ forms can be a pain.
Any suggestions??
————————-
For making check box group mandatory, I made following changes to core files:
-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X- WARNING -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-
Changes to core files is not recommended, as all the changes will be lost on updation
(it can also esckrew your site :P )
-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X- WARNING -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-
File: cform-options.php
Changed line: 375
From: if( in_array($field_type,array('hidden', 'fieldsetstart','fieldsetend','ccbox','captcha','verification','textonly')) )
To: if( in_array($field_type,array('hidden','checkboxgroup', 'fieldsetstart','fieldsetend','ccbox','captcha','verification','textonly')) )
File: cforms.php
Changed line: 818
From: $field .= $nttt . '<li'.$liID.' class="cf-box-title">' . (($field_name)) . '</li>' .
To: $field .= $nttt . '<li'.$liID.' class="'.$liERR.' cf-box-title">' . (($field_name)) . '</li>' .
Changed line: 978
From: else if($field_required == 1 && !in_array($field_type,array('ccbox','luv','subscribe','checkbox','radiobuttons')) )
To: else if($field_required == 1 && !in_array($field_type,array('ccbox','luv','subscribe','checkbox','radiobuttons','checkboxgroup')) )
File: lib_options_sub.php
Changed line: 64
From: if(isset($_REQUEST['field_' . $i . '_required']) && in_array($type,array('pwfield','textfield','datepicker','textarea','checkbox','multiselectbox','selectbox','emailtobox','upload','yourname','youremail','friendsname','friendsemail','email','cauthor','url','comment','radiobuttons')) ) {
To: if(isset($_REQUEST['field_' . $i . '_required']) && in_array($type,array('pwfield','textfield','datepicker','textarea','checkbox','multiselectbox','selectbox','emailtobox','upload','yourname','youremail','friendsname','friendsemail','email','cauthor','url','comment','radiobuttons','checkboxgroup')) ) {
File: lib_validate.php
Added a new else if block around line 158
}else if( $field_type=="checkboxgroup" ) {
### how many checked ?
$all_options = $current_field;
if ( count($all_options) <= 1 && $all_options[0]=='' )
$validations[$i+$off] = false;
else
$validations[$i+$off] = true;
}
That's it