Thread tagged as: Question, Runway

Best way to add a non data based form to a Perch Add on App

Hi All,

i decided to expand the simple instagram integration app in a client project i am working on and extend it from a simple scheduled tasks to have some form admin area, mainly to make the process of generating a new access token simpler if it decides to be revoked.

The general interface went up without a hitch (good work perch team!) but now i am little stuck (using the Mailchimp App as a reference), i am still iffy with the core API.

I want to submit a simple form on my add-on default page, it doesn't persist any data, it will have a token text box for someone to put in the token generated from instagram required to get an access token, but that will simply be used to make a curl call to the instagram API to get the access_token (and possible update a settings field).

I can see in the mailchimp app that there are some forms defined using the Perch:Form tag, but looking at them, they seem like front end forms. But i did try and define a template under the structure:

  • My App --- templates ----- forms ------- get_access_token.html
<perch:form id="getToken" app="instagram">

      <p>Access Token Set</p>

      <perch:label for="token">Instagram Token</perch:label>
      <perch:input id="token" required="true" type="text" />
      <perch:error type="required" for="token">Required</perch:error>
      <perch:input type="submit" value="Submit" id="btnsubmit" />


and then tried to grab some code (appreciate the code is terrible, just trying to get to grips with this by picking apart the Mailchimp App)

    $Template = $API->get('Template');
    $Template->set('forms/get_access_token.html', 'instagram');

    $Form = $API->get('Form');
    $Form->set_required_fields_from_template($Template, array());

   /* ---- FORM ---- */
   echo $Form->form_start('edit');

           echo $Form->fields_from_template($Template, array());

  echo $Form->form_end();
  /* ---- /FORM ---- */

i assumed that i needed to load my form template, and then load the form using that, but i don't seem to get any output, so not sure if i am walking my way up the garden path backwards to be honest and not doing the right thing, and maybe i should use a bog standard form instead for things like this?



Roberto Modica

Roberto Modica 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Your master template should define content for display. Perch will handle turning it into a form. Don't try to build a form in the template.