How do you set the 'relate_to' field when using quickcreate>full form on a subpanel?

Hi,

I have a custom one to many (project_AOS_Products_1) relationship.

A Project detail view shows a AOS_Produts subpanel which has a QuickCreate button. I can create a AOS_Product without issue using QuickCreate.

However if i try to create the record using the ‘Full Form’ button, the record is saved, but the relationship is not.

I can see the hidden field ‘relate_to’ is not being set in the source html of the full form page, although the ‘relate_id’ is being set correctly to the parent Project. Using Chrome, iff i manually change the relate_to field to 'project_aos_products_1 ’ the record and relationship is saved correctly.

I don’t know why the relate_to field is lost when moving from quickcreate to full form? Is this done in the quickcreatedefs?

I managed to solve this :smiley: , and think it’s a bug.

Studio adds the following line to custom/modules/AOS_Products/metadata/editviewdefs.php:

'headerTpl' => 'modules/AOS_Products/tpls/EditViewHeader.tpl',

This stops the ‘relate_to’ field being passed from QuickCreate to Full Form. The first solution was to comment the above line out of editviewdefs, but it gets re-created if you delete the file and i assumed the headerTPL is needed for something else?

Therefore i copied modules/AOS_Products/tpls/EditViewHeader.tpl into the custom folder and changed line 59 from the following:

<input type="hidden" name="relate_to" value="{$smarty.request.return_relationship}">

to this:

<input type="hidden" name="relate_to" value="{if $smarty.request.return_relationship}{$smarty.request.return_relationship}{elseif $smarty.request.relate_to && empty($smarty.request.from_dcmenu)}{$smarty.request.relate_to}{elseif empty($isDCForm) && empty($smarty.request.from_dcmenu)}{$smarty.request.return_module}{/if}"">

I’m not sure how to get to the root of the problem (other than perhaps the relate_to value needs updating?), but it seems to be working ok for me after a quick repair.