Forum

Thread tagged as: Question

Pre-filling the form inputs from a region, using the values from another region

Hi,

I have a list–detail type of page (like the one shown in the portfolio with categories video). On the detail page of a given item, a simple form (coming from another region) is shown based on the expiration date of the item.

perch_content_custom('Campaigns', array(
     'template' => 'campaign/campaign_item.html',
     'filter' => 'slug',
     'match' => 'eq',
     'value' => perch_get('s'),
     'count' => 1,
));

if($results[$arrayKey]['expiration-date'] >= date("Y-m-d")) {
     perch_content('Form');
}

I'm trying to pre-fill the value of an input text of the form with the name of the item. The problem is that there's no direct link because the two regions don't share the same template.

I was wondering if there's a way to carry the value from one region and somehow appending it to the other?

Thanks, Robin

Robin Pick

Robin Pick 5 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use PerchSystem::set_var() to do that. If you pass in a variable, it will pre fill any field with a matching ID.

Thanks, it's perfect.