Access data in perch:form

  • Hi


    I've had this issue years ago and found a workaround, maybe today, there's a better solution?

    The idea is to dynamically populate a form with values from another region.


    I noticed the perch data option as on https://docs.grabaperch.com/te…variables-into-templates/

    Code
    1. $editions = perch_content_custom('Editions',$opts, true);
    2. $opts = array(
    3.     'template' => 'form.html',
    4.     'data' => [
    5.         'edition' => 'first edition'
    6. ],
    7. );
    8. perch_content_custom('Form', $opts);


    But inside the perch:form template we don't manage to render it:

    Code
    1. <perch:input id="someid" type="checkbox" value="edition" />
    2. or also:
    3. <perch:input id="edition" type="checkbox" value="edition" />


    -> This doesn't work. Is there a proper way to get a perch:form input tag that has "first edition" as value?


    ----


    The second step would be to pass in 1-n values.

    The third step to pass in 1-n key-value pairs.


    Then it would be solved.


    Any hints?

  • George G

    Approved the thread.
  • The perch:input namespace is used to generate form fields, but doesn't handle data passed to the template. You'll need to add a perch:content tag inside you value attribute.

    Code
    1. <perch:input id="someid" type="checkbox" value="<perch:content id="edition"/>" />