Hey Friends I want to make a form builder using Yii.
For that I made the database table as:
[user]-> user_id
[form]-> id, user_id
[form_elements]-> form_id
[form_values]-> id, form_id
[table]-> id, form_id, form_elements_id, form_values_id, user_id
I made the model class for the database tables for making them accessible. So for making the form_builder do i need to make them CRUD or make them form generator through Gii tools?
Please help me as I am new to Yii.
If I grasp your schema correctly, you're about to make a layer on top of CForm. Your application will presumably have two interfaces:
one that is generating forms based on the data in your database, and accepting end-user inputs,
and another that will manipulate the form fields.
For the first, you need to develop a special library to interpret your data into CForm configuration and store the input in a separate database (and by separate I mean a database that is not covered in your specs above).
For the second, yes, you will need a CRUD application (as a start at least) to deal with those objects in a convenient way.
Related
I just started to work in symfony 3.4 and i'm pretty lost.
I want to make a CRUD for Products.The products table have multiple columns(name,description,CATEGORY_ID).
In create page, for this category_id, i want to make a select with the names of the categories that are stored in another table(id and category_name).
For this i need to select all the categories, but i don't really know how to do that.
I worked in codeigniter before and there i would make a function getAllCategories in category_model and i would call it in Controller.But here...i don't know how to do this.
Can you explain to me please how this should work?Where should i make the sql functions?
Your seem lost on things that are very basic for Symfony.
You probably have to start reading a lot and from the start.
You have two parts that you have to cover.
One is doctrine and how you can declare entities and manage them with the entity manager, and the second is Forms and how you can use them to render your form (including the foreign entity relation), to handle and validate your submitted data, and to pass the validated data to the database through the entity manager.
Your example is pretty simple, so it should be very easy to follow a tutorial while modifying it to fit your code.
I have a new type project. Please help if you can. I have a user management project in which i have many tables lets say user table.
table user
fields user_id , user_f_name , user_l_name, user_username.. etc. this table is encrypted in real like
RM_999(this is name of encrypted table)
RM_0999, RM_1999 , RM_2999 , RM_3999...
I the same manner all tables and columns are encrypted for sake of security.
But i have yii project written in simple names like user_username (As it was already made project which i used for variouus project). But now i don't want to changed my code for that encrpted database. Is there is any way bye which i can use my written code without changing it.
Any help will be appreciated.
It depends on how your existing application code is written.
The below approach may solve your problem
In your project, if there are entity classes for all tables in DB which extends CActiveRecord then you can use attributeLables() so that you can map your existing column names to encrypted column names. (Assumed that your application code access that table attributes via labels).
I have been tasked with creating an application that allows administrators to alter the content of the user input form (i.e. add arbitrary fields) - the contents of which get stored in a database. Think Modx/Wordpress/Expression Engine template variables.
The approach I've been looking at is implementing concrete tables where the specification is consistent (i.e. user profiles, user content etc) and some generic field data tables (i.e. text, boolean) to store non-specific values. Forms (and model fields) would be generated by first querying the tables and retrieving the relevant columns - although I've yet to think about how I would setup validation.
I've taken a look at this problem, and it seems to be indicating an EAV type approach - which, from my brief research - looks like it could be a greater burden than the blessings it's flexibility would bring.
I've read a couple of posts here, however, which suggest this is a dangerous route:
How to design a generic database whose layout may change over time?
Dynamic Database Schema
I'd appreciate some advice on this matter if anyone has some to give
regards
SWK
I created a very large EVA database years ago (PHP w/ PostgreSQL). It turned out great, but it was large project ($$$). All the forms were completely dynamic, with form/field versioning, publishing workflows, matching dynamic reporting, etc.
EVA basics are easy enough. Getting data in is not the hard part. But form versioning and reporting....you can spend years getting it right.
If I was doing it again today, I would research using one of the newer NoSQL solutions ( http://en.wikipedia.org/wiki/NoSQL#Document_store ). I'd thing about creating a DTO style class that could be passed to a form generator. "Modifying" the form, would actually be modifying the DTO. Then I would persist that DTO into a document/object database.
Also, as you are building your alpha solution, think of how to solve test cases that encompass versioning and reporting needs.
Here is an example of what I mean: A simple "Ask Question form".
Original (version 1): has First,Last,Question
Add email field(Version 2): First,Last,Email,Question
Somebody changes their mind about email: (version 3): First,Last,Question
New marketing guy comes in and changes it: (version 4): Full Name,Email,Question
Now, you need to generate a report (csv). Things get tricky. How do you do it?
We solved this problem with field level versioning with references to their previous versions. Plus the reporting system required the end user to assemble the definition of the report data sources before running. (binding report fields to data fields, etc).
However with the document DB's I'd imagine you can do it differently. I believe the new DB's like CouchDB (others??) have mechanism built in for handling these issues.
Good luck!!
When developing user profiles in my last webapp, I've chosen Key/Value table approach. Here's how my DB design looks:
Users table with fixed columns:
id
login
name
regdate
Users table linked with Profiles table (User HasMany Profile).
Profiles table with different data:
user_id
field
value
This way user can add any additional field to his profile. For example:
user_id = 1
field = 'Facebook'
value = 'http://facebook.com/...'
and
user_id = 1
field = 'Stackoverflow'
value = 'http://stackoverflow.com/user/...'
and so on..
Depending on your needs, it might not be worth even raising the form fields to the "DB fields" level. You could instead serialize these fields in (what is essentially a) dynamic blob and store it in the DB. This is NOT recommended if you have folks who need to query these dynamic fields outside of your app (i.e., the DB design is part of a larger public contract with integrated systems), but if you're just using the app to simply to persist these dynamic fields or if any aggregation/search capabilities within the fields are minor, then I would consider it (esp given CPU capabilities these days). I have used the pattern many times and I have - thus far - never had to refactor. (however, I can understand a case where you might need to).
I'm currently researching a project for the place that I work in. We are trying to create a system that will allow forms to be set up dynamically from a database.
My question is what database structure would best suit something like this?
I currently have a structure of:
forms_form
forms_formfields
forms_formdata
I don't think this is the most appropriate layout for this. Basically to make is make sense I need to be able to make a form within the database that can have infinite fields all customized and have the data when submitted stored in the database.
The proposed structure looks ok to me. form -> field is clearly 1:M relation, so you'll need forms(id,...) and fields(id, form_id, type, ...). field->data is kind of 1:1, so theoretically a separate table is not needed, unless you allow one form to be used with different sets of data. If this is the case, i'd suggest datasets(id,...) and data(field_id, dataset_id, value).
An online application we are building (php & mysql) requires users to be able to create their own forms for data capture and record this data in a database, respecting the existing ORM's.
If the forms where "hard coded" then we would simply set the db tables up to store the normalised data ourselves however as our users define the form fields contained in the forms, we're not sure what is the best way to proceed to implement this functionality.
Do we need to think about some kind of meta data or data abstraction layer for our DB? Google hasn't been too much help as we're unsure about how we need to go about this.
Any pointers in the right direction would be gratefully appreciated!
Many content management systems address this problem in different ways.
For example, in Drupal, users can create their own custom content (with custom forms) through the CCK module. The module defines different types of fields that the user can create, then generates tables with specific data types to store the data.
Some tips:
Define your field types - Think about giving the users a choice of different field types (e.g., select box, string, radio).
Create tables for user defined fields - Each field type will have a specific SQL data type. Define a table using these data types. For example, a select box might be mapped to an enum and a input text element might be mapped to a varchar column.
Add data to the new tables - use the new tables to store the data in a somewhat normalized way.
Obviously there are many different approaches, but these are just a few suggestions.
I think I've found a solution to my problem, so for all those people who come along a similar problem have a look at the following artcles -
http://www.adaniels.nl/articles/an-alternative-way-of-eav-modeling/
http://weblogs.sqlteam.com/davidm/articles/12117.aspx
Hope this helps.