It is possible, just prepare your form and controller.
In the view.html.php i created several instances of the needed models. Of course you need to set the correct queries to collect the data, i only submitted the code for the models:
$model = $this->getModel();
//get the subpropertyitem
$subpropertyitem = $this->get('data');
$model_booking = JModel::getInstance('bookingitem', 'Mw1bookingModel');
$bookingitem = $model_booking->get('data');
$model_address = JModel::getInstance('bookingitem', 'Mw1bookingModel');
$addressitem = $model_address->get('data');
$this->assignRef('subpropertyitem', $subpropertyitem);
$this->assignRef('bookingitem', $bookingitem);
$this->assignRef('addressitem', $addressitem);
Next in the form template you need to use the correct dataObject for the correct fields, examples:
<?php echo JDom::_('html.form.input.calendar', array(
'dataKey' => 'dt_till',
'dataObject' => $this->bookingitem, // object for the booking
'dateFormat' => $this->config->get('date_format'),
'required' => true
));
<?php echo JDom::_('html.form.input.text', array(
'dataKey' => 'last_name',
'dataObject' => $this->addressitem, // object for the address
'size' => "32",
'required' => true,
'validatorMsgRequired' => "MW1BOOKING_VALIDATOR_LAST_NAME_IS_REQUIRED",
'validatorHandler' => "length_100",
'validatorRegex' => "/^.{2,100}$/",
'validatorMsgInfo' => "MW1BOOKING_VALIDATOR_LAST_NAME",
'validatorMsgIncorrect' => "MW1BOOKING_VALIDATOR_INCORRECT_LAST_NAME_AT_LEAST_2_CHARACTERS_REQUIRED"
));
In the controller i created a new function, in my case savebooking. Of course in the view.html is refer to this function:
$bar->appendButton( 'Standard', "save", "MW1BOOKING_JTOOLBAR_SAVE", "savebooking", false);
In the save_booking function i save the data in different tables.
$model_addressitem = JModel::getInstance('addressitem', 'Mw1bookingModel');
$model_bookingitem = JModel::getInstance('bookingitem', 'Mw1bookingModel');
$model_addressitem_save = $model_addressitem->save(JArrayHelper::toObject($post));
if ($model_addressitem_save) {
$post['address_id'] = $model_addressitem->_id;
$model_bookingitem_save = $model_bookingitem->save(JArrayHelper::toObject($post));
}
Of course this is only the basic code. For example i first save an address record, after that i save the booking record. If saving the booking record fails you maybe want to delete the address record.
Another possibility is to save the data in a transaction. Then there is the function rollback all queries in a transaction when one of the queries failes. But then you need to do some more programming.