Submit Form return in same block

I have a block on a page that has a narrative of information that was entered into the database.

block1267 image

In the upper right corner of the block, I have the Edit link, which opens the form in the same block (link code: <a class="top_members_menu" onclick="return !loadDynamicBlock(1267, this.href);" href="https://caredesign.net/m/clients/AddInitialContact?client=c6yz3YiX"></a>).

block1267 form image

With dolphin Forms submission and checking, after clicking the submit button, the form would normally run through the checker functions and check that, but to do so, it submits to itself. So, how do I code the action line so that it reloads the page, with the proper content in block 1267 instead of the default content?

 

This is the code for the function that displays the form:

 

function actionAddInitialContact ()
    {
        $client = $_GET['client'];
            // Demographics Section
       
        $aForm = array(

            'form_attrs' => array(
                'name'     => 'form_search_books',
                'action'   => BX_DOL_URL_ROOT . 'm/clients/AddIc?client=' . $client,
                'method'   => 'post',
            ),

            'params' => array (
                'db' => array(
                    'submit_name' => 'submit_form',
                ),
                'csrf' => array(
                    'disable' => true,
                ),
            ),

            'inputs' => array(
        'client_id' => array(
            'type' => 'text',
            'name' => 'client_id',
            'caption' => _t("_client_id"),
            'value' => $client,
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'AloneOrNot' => array(
            'type' => 'radio_set',
            'name' => 'AloneOrNot',
            'caption' => _t("_AloneOrNot"),
            'required' => true,
            'values' => array(
            'Yes' => 'Yes',
            'No' => 'No',
            ),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'WhoIsHelping' => array(
            'type' => 'text',
            'name' => 'WhoIsHelping',
            'caption' => _t("_WhoIsHelping"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'Location' => array(
            'type' => 'text',
            'name' => 'Location',
            'caption' => _t("_Location"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'SIComments' => array(
            'type' => 'text',
            'name' => 'SIComments',
            'caption' => _t("_SIComments"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'HIComments' => array(
            'type' => 'text',
            'name' => 'HIComments',
            'caption' => _t("_HIComments"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'DangerComments' => array(
            'type' => 'text',
            'name' => 'DangerComments',
            'caption' => _t("_DangerComments"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'Psychosis' => array(
            'type' => 'text',
            'name' => 'Psychosis',
            'caption' => _t("_Psychosis"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'CapacityYN' => array(
            'type' => 'text',
            'name' => 'CapacityYN',
            'caption' => _t("_CapacityYN"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'CapacityComment' => array(
            'type' => 'text',
            'name' => 'CapacityComment',
            'caption' => _t("_CapacityComment"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'ContractForSafety' => array(
            'type' => 'text',
            'name' => 'ContractForSafety',
            'caption' => _t("_ContractForSafety"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'SafetyPlanComments' => array(
            'type' => 'text',
            'name' => 'SafetyPlanComments',
            'caption' => _t("_SafetyPlanComments"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'InsuranceIssues' => array(
            'type' => 'text',
            'name' => 'InsuranceIssues',
            'caption' => _t("_InsuranceIssues"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'Stressors' => array(
            'type' => 'text',
            'name' => 'Stressors',
            'caption' => _t("_Stressors"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'InitialContactInstructions' => array(
            'type' => 'text',
            'name' => 'InitialContactInstructions',
            'caption' => _t("_InitialContactInstructions"),
        ),
        'KnownMed' => array(
            'type' => 'text',
            'name' => 'KnownMed',
            'caption' => _t("_KnownMed"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'GeneralHealth' => array(
            'type' => 'text',
            'name' => 'GeneralHealth',
            'caption' => _t("_GeneralHealth"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'PresentingProblem' => array(
            'type' => 'text',
            'name' => 'PresentingProblem',
            'caption' => _t("_PresentingProblem"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'NextAppDate' => array(
            'type' => 'date',
            'name' => 'NextAppDate',
            'caption' => _t("_NextAppDate"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'NextAppHour' => array(
            'type' => 'text',
            'name' => 'NextAppHour',
            'caption' => _t("_NextAppHour"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'addictions' => array(
            'type' => 'text',
            'name' => 'addictions',
            'caption' => _t("_addictions"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'treatment_comments' => array(
            'type' => 'text',
            'name' => 'treatment_comments',
            'caption' => _t("_treatment_comments"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
        'med_note' => array(
            'type' => 'text',
            'name' => 'med_note',
            'caption' => _t("_med_note"),
                    'db' => array (
                        'pass' => 'Xss',
                    ),
        ),
                'Submit' => array (
                    'type' => 'submit',
                    'name' => 'submit_form',
                    'value' => _t('_Submit'),
                    'colspan' => true,
                ),
            ),
        );
       
       
         $oForm = new BxTemplFormView ($aForm);
        $oForm->initChecker();
       
         if ($oForm->isSubmittedAndValid ()) {
            // add additional vars to database, in this case creation date field is added
             $aValsAdd = array (
                
             );
 
             echo 'insert last id: ' . $oForm->insert ($aValsAdd); // insert validated data to database
         }
   
    echo DesignBoxContent(_t('_initial_contact_form'), $oForm->getCode (), 1);

    }

 

Any assistance would be greatly appreciated. Thanks in advance.

block 1267.png · 266K · 182 views
block 1267 form.png · 734K · 196 views
caredesign.net
Quote · 17 Mar 2014

bumping in case someone knows something.

caredesign.net
Quote · 19 Mar 2014

badump a bump bummm

caredesign.net
Quote · 21 Mar 2014

anyone?

caredesign.net
Quote · 27 Mar 2014

The good options would be to perform form submission via AJAX without page reload, there is jquery plugin for it in Dolphin by default:

plugins/jquery/jquery.form.js - http://jquery.malsup.com/form/

Rules → http://www.boonex.com/terms
Quote · 31 Mar 2014

thanks Alex, I figured it would have something to do with AJAX, but I have not specifically used AJAX before so not exactly sure how to implement it. Plus, dolphin has their way of implementing things, so doubly confused on how to make it work with AJAX. I tried putting the page that would do the form checking, but it keeps redirecting to that page, instead of doing what needs to be done in the background.

caredesign.net
Quote · 31 Mar 2014

 

thanks Alex, I figured it would have something to do with AJAX, but I have not specifically used AJAX before so not exactly sure how to implement it. Plus, dolphin has their way of implementing things, so doubly confused on how to make it work with AJAX. I tried putting the page that would do the form checking, but it keeps redirecting to that page, instead of doing what needs to be done in the background.

 Maybe something like this should work for you:

    $(document).ready( function() {
         $('#your-form-id-here').ajaxForm({
            success: function(data) {
                if (1 == parseInt(data)) {
                    alert('Form was successfully submitted');
                    // reload page block here 
                } else {
                    alert('Form contains error');
                }
            }
        });
      }
    );

on the server side, something like this:

        $oForm = new BxTemplFormView ($aForm);
        $oForm->initChecker();
        
         if ($oForm->isSubmittedAndValid ()) {
             echo 1;
         } else {
             echo 0;
         }

this is simple variant without form errors highlighting, but can be easily extended for it.

Rules → http://www.boonex.com/terms
Quote · 7 Apr 2014

cool - thanks a lot. I will work with this and see what I can manage to get out of it. I really appreciate it.

caredesign.net
Quote · 7 Apr 2014
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.