Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Conditional forms with JQuery plugin

Started by Muut Archive 9 years ago · 3 replies · 1259 views
9 years ago

Hi guys,
I want to build a form with conditional fields (shown or hidden based on the field values of other fields). I could use a jQuery plugin (http://www.jqueryscript.net/form/jQuery-Plugin-For-Conditional-Form-Fields-conditionize-js.html) to make things easier but I would have to extend the GRAV forms plugin to accept new markdown attributes (data-cond-option and data-cond-value) to make it work. The rendered field html has to be wrapped with a div with extra attributes like this

HTML
<div class="conditional" data-cond-option="example" data-cond-value="yes">  
.......  
</div>

How can I make GRAV process field markdown like this:

YAML
-
      name: mytextfield
      label: Your Name
      type: text
      classes: conditional
      data-cond-option: example
      data-cond-value: yes

Or is there a better way to build conditional form fields in GRAV?

9 years ago

Sorry - please replace markdown with YAML frontmatter

9 years ago

Thank you for your answer. Unfortunately I can't get this working. Could you please give a more concrete example?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2933 9 years ago
Archive · by Muut Archive, 9 years ago
3 1110 9 years ago