mrjmd / pdb

Decoupled Blocks is a Drupal 8 module to simplify integrating javascript frameworks into your site.
https://www.drupal.org/sandbox/mrjmd/2664138
57 stars 14 forks source link

Per instance settings #6

Closed mrjmd closed 8 years ago

mrjmd commented 8 years ago

In the original version of this code for TWC, we have the ability to create instance configuration fields directly in the metadata file (was JSON originally, now YAML), using a JSON-ified version of Drupal's form API.

We will need something like this for decoupled blocks as well, possibly built on top of this: https://www.drupal.org/project/yamlform

mrjmd commented 8 years ago

Looking into this now.

mrjmd commented 8 years ago

I spoke with Jacob Rockowitz (creator of the module above) on IRC and he linked me to this piece of code that builds the forms:

http://cgit.drupalcode.org/yamlform/tree/src/YamlFormSubmissionForm.php

Excerpt from our conversation below:

jrockowitz: The form is built via http://cgit.drupalcode.org/yamlform/tree/src/YamlFormSubmissionForm.php [11:13am] jrockowitz: But each FAPI element has a YamlFormElement plugin which is wrapper that contains methods to prepare and populate the form elements. [11:13am] mrjmd: Are there form elements from FAPI that aren’t supported yet? [11:14am] jrockowitz: No yet but I needed this wrapper to normalize and fix certain complex elements like entity_autocomplete and text_format [11:16am] jrockowitz: I am looking over my code and for almost all basic HTML form elements you can use #default_value without any problems. [11:18am] jrockowitz: I think checkboxes and multiple select menu will need to some help. When I started out I just used a switch case based on the #type.

mrjmd commented 8 years ago

The PR is here: #46

Is has been approved and merged, great first start.

mrjmd commented 8 years ago

I've fixed this up a bit more so that the configured field in the example is fed forward to the template for use. This behavior should really be an external service.