Form with a variable value in hidden input

Hi, I've created function like this:

function genForm($iId) {

 

            $aForm = array(

 

                'form_attrs' =>array(

                    'name' => 'add_friend_to_event',

                    'action' => '',

                    'method' => 'post',

 

                ),

 

                'params' => array (

                    'db' => array(

                        'table' => 'events_users',

                        'key' => 'id',

                        'submit_name' => 'submit_form',

                    ),

                ),

 

                'inputs' => array(

                    'nickname' => array(

                        'type' => 'text',

                        'name' => 'id_participant',

                        'db' => array(

                            'pass' => 'text'

                        ),

                    ),

 

                    'hidden' => array(

                        'type' => 'hidden',

                        'name' => 'id_event',

                        'values' => $iId,

 

                    ),

 

                    'submit' => array(

                        'type' => 'submit',

                        'name' => 'submit_form',

                        'value' => _t('_Submit'),

                        'colspan' => true,

                    )

                )

            );

 

        return $aForm;

    }

 

And I've got a loop foreach like this:

foreach ($aEvents as $sKey => $aRow) { // add human readable values to the resulted array

 

            $iId = $aEvents[$sKey]['Id'] = $aRow['Id'];//$form = array ()form arrays itd type hidden value = aevents[idevents]

            $aEvents[$sKey]['Subject'] = $aRow['Subject'];

            $aEvents[$sKey]['Description'] = $aRow['Description'];

            $aEvents[$sKey]['Location'] = $aRow['Location'];

            $sStartTime = ($aEvents[$sKey]['StartTime'] = $aRow['StartTime']);

            $sEndTime = ($aEvents[$sKey]['EndTime'] = $aRow['EndTime']);

            $iIsAllDayEvent = ($aEvents[$sKey['IsAllDayEvent']] = $aRow['IsAllDayEvent']);

            $addFriend = $this->genForm($iId);

 

            bx_import ('BxTemplFormView'); // import forms class

            $oForm = new BxTemplFormView ($addFriend); // create foprms class

            $oForm->initChecker(); // init form checker

            $form = $oForm -> getCode();

 

            }

 

In aVars I've got  

  $aVars = array (

            'history',

            'bx_repeat:posts' => $aEvents,

            'form' => $form,

        );

        

And in edit.html I've got this: 

         <tbody>

        <bx_repeat:posts>

        <tr>

            <td>__Id__</td>

            <td>__Subject__</td>

            <td>__Description__</td>

            <td>__Location__</td>

            <td>__StartTime__</td>

            <td>__EndTime__</td>

            <td>__form__</td>

        </tr>

        </bx_repeat:posts>

        </tbody>

</table>

 

I've got a problem, beacause I want to put to form id of each event, ad then user who want to add a friend to event type his name and then, after submit function put into database two values: id_user and id_event, but I have no idea how to do this. Can you help me?

Quote · 16 May 2014

I could be mistaken, but replace your 

 

return $aForm;

with something like:

$oForm       = new BxTemplFormView($aForm);
        $oForm->initChecker();
        if ($oForm->isSubmittedAndValid()) {

          $aValsAdd = array (
            );
            if ($oForm->insert ($aValsAdd)) {

$sStatusText = '_successfully_added_friend_to_event';

}

if($sStatusText) {
            $sStatusText = MsgBox(_t($sStatusText), 3);   

}
        return array($sStatusText . $oForm->getCode(), array(), array(), false);

        }

 

This is not 100% correct. I am just posting code that I know works for me, but not seeing your full page and your exact layout of your code, it is hard to give you the appropriate answer. If you could post the whole page code, that would really help out, and also maybe the url - if possible.

caredesign.net
Quote · 16 May 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.