Creation of dynamic datafields cakephp - php

I have planned to create tables for dynamic datafields. My concept is to store a dynamic form data inside tables(MySQL). The user can select any number of fields(datatypes) from form.The form is a dynamic form one seen in here . How can we design dB in order to save user's data dynamically?

Can you not just allow for fields within the database to be null. That way when you save the form if any fields have not been filled it doesn't throw an error

Seems, you need to implement EAV data model wiki link Also, there are some ready solutions
some project on github
EAV behaviour on bakery, also one of project from github
expandable behaviour

Related

Move form entries between Wordpress Gravity Forms

I have a tournament with multiple divisions and multiple forms for which I use gravity forms.
There are times when someone requests to be changed to a different division. However, I am unable to move the competitor from one division to another in gravity forms, as the divisions are each using a different form ID (and they have still not developed a method for helping with this).
How would I go about moving a SINGLE ENTRY from one gravity form to another forms entry list please.
We have many teams at the tournament, so mass export and import is not what i am looking to achieve. Its about being able to move a single entry from one list of entries in one form to another forms list of entries?
ANY help would be greatly appreciated. Even a simple "use this method" in general terms will help me greatly. Would I use some form of JQuery fiddle, a php script, an sql script or what please as Import Entries is not available currently in GF
Regards
You can not do that, but instead maybe you shold design your form to include all types of submissions logic. I mean you can put a drop-down field at the beginning of your form. Then you can use https://gravityview.co/ to edit your single entry field.
I have a workaround for this which i am using in one of my current projects for http://projects.dzign-r.com.au and that is,
1) export both of the the forms (i.e the one from which you need the field to move and the other to which you need this field to be moved to) and it exports these as json files
2) search for the field ID that you need to be moved to another form, cut its json code from the json file and paste it in the other form's json file where you need it to be moved to
3) then import the form back. and test it to make sure it works as you want it, (as a caution you may change the field ID after you paste it in new form to be something which is not used in this form already).
4) once u see everything is fine u may just delete the old form?

Pulling data from MySQL into an Elgg application

I'm trying to use Elgg as a starting point for a certain type of social media website. One of the main things I'd like to do is allow users to create events and then display all the events in a sortable table (sortable by different attributes given to the event during the creation like date and title). For the event creation aspect, I'm using the plugin Event Manager.
I'm assuming the best way to do this is to pull the event data from where ever it is stored and put it into an HTML table (I'm using the jQuery TableSorter code). Can anyone give me a good idea of where and how to start doing this?
The biggest problem I'm having is finding where the event data is stored in MySQL.
For the database organisation and model, read:
http://docs.elgg.org/wiki/Engine/DataModel
http://docs.elgg.org/wiki/DatabaseSchema
For fetching the data, consider using:
http://reference.elgg.org/1.8/engine_2lib_2metadata_8php.html#aec4b6f0b9565e3554acb9b39ef34a2ac
With options order_by and order_by_metadata for chosen information.

How to create a site-search in Symfony2?

I started creating own Symfony bundles some weeks ago. I've created some entities with all the stuff around (also used the Doctrine CRUD-command), made some twig extensions and created new templates.
Now I wanted to implement a Search Form in my Project. Are there some simlpe ways or some predefined Search-Bundles, which I can use in my Project?
I created my search-form manually (form without an entity). Then form is submitted via GET and the Results (selcted from the Entities in the Controller with a repository-search) are shown below the search form on the same page.
Now I think, that it isn't good to have a very long URL, because of the Fields in the Form. I could go further and submit e.g. a <select> list with multiple entries selected and the URL would even be longer.
Would it be a good choice to submit the Form via POST, "cut" the unnecessary "URL-Array-Elements" (+make the Query-Items more readable for humans) and redirect to the URL with the queries for showing the results?
Edited: Are there any simple ways, how I can create a specific search form or entity-filter which I can use for custom entities? I like to use/create a function, where I can insert the entity, define the search-tags/filters and output a search-form? Has anyone created/used such search/filter-functions?

Adding input fields to a cakephp form through admin

I am struggling to find out if I can do this but I have a cakephp form with many input fields and when submitted I write them to a text file I can add fields in dynamically here by clicking a button but:
My question is if I have an admin page how do I get that to dynamically add fields to the page and make them stay there forever not just for that session?
Really stuck figuring out how to do this any guidance would be much appreciated.
Thanks in advance.
Make them persistent. You need to store the form and the fields it has: "Form hasMany FormField". The fields should describe a type so that the FormHelper will render the correct inputs.
When you want to display the form read that information from the db again and render the form according to your stored information.
I am guessing you already have a javascript function that dynamically adds the field to your admin page. Is that correct?
I don't use CakePHP, but a general workaround I use is to use the javascript function to at the same time update a table in the database that stores the form layout.
Here are some Jquery Form builder plugins that you can use to achieve the goal.
http://www.berthou.com/us/2009/09/05/dynamic-forms-builder-with-jquery/
https://github.com/botskonet/jquery.formbuilder
http://code.google.com/p/jquery-form-builder-plugin/
http://www.elizaibeth.com/2010/11/23/dynamic-jquery-form-builders/
Here is an excellent link of PHP FormBuilder class with tutorial, that you can use as a vendor library into CakePHP.

Can I use dynamically created form fields with the Security Component in CakePHP 1.3?

Using CakePHP 1.3, I have a (working) form that has dynamically created form fields (via Javascript). Everything works great, multiple models are saved via saveAll(), and it's just beautiful.
But, I get black-holed to a 404 whenever I enable the Security component (hoping to get some of the auto-magic CSRF protection).
I understand that this may be (probably is!) caused by the dynamically created form fields, as mentioned in the docs.
Is there a way to get them to play nicely together?
You can't have your Cake and eat it, too. (Cha-ching!)
CSRF protection means precisely that only a certain list of form fields is allowed to be submitted. This list is decided upon and fixed at the time the form is created. You can't be CSRF protected and dynamically alter the fields in the form.
There are two solutions:
If the number and names of the dynamically created fields are limited, create them all in the form and hide them using CSS, then show them using Javascript. This way you're not dynamically creating the fields, but are only dynamically showing them.
If that doesn't work, you can either whitelist the fields using the $disabledFields option (again, only if their names are known in advance) or disable CSRF altogether with the $validatePost option.

Categories