Meteor dynamic form fields generation - meteor

I am building a testing app where admin can build up questions for each test, each test will have its own set of fields (text, drop down, checkboxes, radio...etc), so I was wondering if there is any Meteor package that can help me with the dynamic form generation?
I've checked aldeed: autoform but as far as I understood all form fields (schema) must be defined statically, while in my case it is dynamically generated, saved/ retrieved in/ from the tests collection, where I save each test along with its fields (label, type, min, max...etc). Thanks

Autoform could automatically create your form based on a schema as it uses simple schema (or alternatively collection2). You could store and update your schema in the DB serialized for example and then use it with parseJSON.
var schema = $.parseJSON(jsonFromDB);
CollectionSchema = new SimpleSchema(schema);
{{> quickForm schema=CollectionSchema}}
Not tested but I think it should work.

Related

Magnolia detail subapp commit action

I'm on magnolia 6.2.15 and I need to generate data from some fields that users insert in a content detail subapp.
I thought about creating a subclass of magnolia "SaveDetailSubAppAction", in the "execute" method to do the job.
I can retrieve fields value but, how can I generate new fields data values and insert that in the form before validation and commit to jcr datasource?
Well you can't. Or rather you shouldn't. The form is means for user to enter the data. If you create data programatically, you either send it directly to the datasource or store it directly on the node that datasource operates on.
If you want to show generated data to user for approval prior saving, then you need to create custom field that would have the place for extra input and would react on user generated input directly prior to saving content.

meteor dynamic schema usage

I plan to build a dynamic schema and create an autoform from that schema. In the template where the form will be displayed I plan on doing this in
template.formPage.onCreated(function(){//do stuff});
What I am curious about though is getting the form onto the page:
Can I just use the usual AutoForm helper to generate the form directly in the template ie quickForm or would I need to create a new template helper to pass details from the newly created schema to the template?
Bit confused about what's supposed to happen where.
To be more concise: the user can create a document called exercise for example: this would have a name field, a description field etc and they could also decide what the measurable units are, these are stored as sub documents, each sub document has 3 fields: name, value, unit. I created a schema and sub schema and this works fine.
The issue is that when a user is doing a workout they should be able to select an exercise from the collection of exercises (all of which are created by the admin) and from that data create a form (read schema) to upload a document to the workout collection.
The measurable values in the exercise document will describe what form fields are required in the workout form depending on what exercise is being performed.
Essentially the exercise collection is a collection of schemas.

Symfony Mapping in Doctrine without Annotations or XML Files

a customer has an existing database. The schema is often changed within the database itself (e.g. he adds a new column).
My task is to develop an admin area with symfony that automatically reacts on table schema changes without modifying the application code. E.g. the customer adds a new column to table "MyEntity", and the application automatically generates a new column in the accordingly list view.
My approach is to dynamically map the table columns to the Entity class so that ALL Attributes and ALL Getters/Setters are generated dynamically from the table schema.
So is it possible to map the table columns in a Doctrine Entity without the use of Annotations or XML Files.
Something like:
class MyEntity{
public function generateMappingFromSchema($sTableName){...}
}
Please don't do that. Doctrine was not designed for such use case.
There is a library though you should check https://github.com/laravel-doctrine/fluent which basically is a mapping driver that allows you to manage your mappings in an Object Oriented approach. And there are other tools:
http://crud-admin-generator.com/
http://crudkit.com/
http://www.grocerycrud.com/
which are maybe better for that, I don't know.
But again, please don't do that. Do not allow the customer to modify the database schema or give them e.g. a phpMyAdmin which was designed for that.

Combining data and form

I am writing a module in Drupal 7, that shows some data from database using theme('table').
It works great and now I would like to add some data filtering by a date and a category using
textfield and a select box.
How do I combine those two?
Your theme function returns the formatted output according to an array you pass as a parameter. So you have to filter the contents of your array before passing it to the theme function. Create your form elements using Drupal's FAPI, in the submit function of your form pass the parameters needed in your page's query string and use these values to filter/create your array before passing it to your theme function. Usually you use these parameters to filter your SQL query to the database itself.
As an example on how to implement this submission function: How to make a form self referencing in Drupal? Or any other options?
Also, check out Drupal's core search and dblog modules as references. The reports page in Database Logging has a filter and the Search module implements a search passing parameters.

umbraco and custom system table

I have the following scenario:
My website db has a system table called "Companies", which includes an id field, companyName field, and companyImageUrl field.
How do I set up an umbraco document type for adding entries to this table ?
Maybe I shouldn't use a custom table at all ?
Thanks.
As far as I know, Umbraco doesn't support what you want to do out of the box (mapping a document type to a table that isn't part of the umbraco core).
One approach that might work is to create an action handler that syncs a Company doc type to your table when creating a node of that type.
It's a bit of a hack though. I've found that I've very rarely needed to create custom tables. What exactly are you trying to do with it? My guess is that you don't really need it and would be better off working with a doc type instead. Umbraco provides a variety of ways to get and act upon doc types from within custom C# code (check out the umbraco.NodeFactory namespace). You'll also get the added benefit of being able to easily interact with these nodes from XSLT/Razor.

Resources