Is it possible to dispaly form data with views ?

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by tejaspmehta on April 24, 2010 at 6:15am

Hello Everyone,

I have started using drupal from few days. Based on requirement i found some modules and use them in websites. Currently i am working on one website. At that time i found views and it is a charming module which helps a lot to display records or create reports.

Now i have different type of question. Is it possible to display text box or select area or check box or radio button in view ?

I have created on view in which i have displayed Product name and price and Add to cart button. (this is provided by ubercart but some modification made by us according to requirement). Now problem is all product has attribute and it must be selected. Now my question is if it is possible that i can show attributes as form in views ? if yes how ? i tried but didn't find any related item. I have also attached image that what i want and what is currently displayed.

Thank you
Tejas Mehta

AttachmentSize
question.JPG 28.23 KB

Comments

Is it possible to display

Posted by scottprive on April 25, 2010 at 12:05am

Is it possible to display text box or select area or check box or radio button in view ?

Yes and No.

Views does not directly accept or produce anything with data still contained in a form.
Views displays data which already exists in a database somewhere.
So if you save the "form data" to a database, then yes Views can (potentially) access that data.

I say "potentially yes" because there is a problem - Views works best with data which is saved in the SAME database as Drupal.
If this is where your data is saved, then no problem.. you may need to write some boilerplate PHP code to views-enable your data, but there are plenty of tutorials for how to do that. So "yes".

Another scenario is if your form data is saved on the same database server (same PC) as Drupal -BUT- the data goes into a different database, then the answer us :maybe yes" (it can be done but it is an advanced solution).

Now if your form data gets saved into another database server (not on the same machine as Drupal), then the answer is no, not if you want to Join that data to the Drupal database (user info or node info, etc). Views just prepares queries and sends them to your database and there is no straightforward way to query a JOIN against 2 databases on 2 systems.

I don't yet know much about Ubercart or what you are doing, but hopefully this answer gets you looking in the right direction.

-Scott

Hello Scott, Thank you for

Posted by tejaspmehta on April 26, 2010 at 10:45am

Hello Scott,

Thank you for your reply.

Based on your comment i found that i have to write some code in views to make it work. Just to provide you overview i have single database which stores details of drupal and related modules.

I am learning drupal so it might be possible that direction you showed me to make php code will work slowly for me. i will try to find such type of solution, but if you have any reference or other item which can help than do post it here.

Thank you for your time.
Tejas Mehta.

Hello Tejas, Yes, unless the

Posted by scottprive on April 26, 2010 at 12:22pm

Hello Tejas,

Yes, unless the database fields are "node aware" (Drupal or CCK data) then yes you need to write some code. It is mostly boilerplate code, a $data array which describes structure and field types of the database fields so Views will know how to manage the display.

For documentation, it is unfortunately scattered in several places (at least, from the point of view of a novice). The first thing is to install module Advanced Help, because it will expose the Views 2 API documentation. The Views 2 API documentation is just that - API docs. It's not a tutorial or walk through or a tear-down of example code. Just pointing that out because searching the Internet is key to finding explanations.

I found this tutorial series helpful:
http://www.stevekarsch.com/2008/11/06/scratching-itch-introduction
http://www.stevekarsch.com/2008/11/08/scratching-itch-building-myweather
http://www.stevekarsch.com/2008/11/30/scratching-itch-myweather-views-2

I found this one this morning - it goes a little more into Views Handlers (you may not need custom handlers...)
http://blog.menhir.be/2008/10/22/expose-database-fields-to-views-in-a-cu...

Last and best place is for help is to download a Drupal module which has Views integration, and study that code. That sounds like it could be a lot of time, but there are lots of very small Drupal modules which support Views... small modules are good because you can quickly see how things work by example.

-Scott

Hello Scott, once again thank

Posted by tejaspmehta on April 26, 2010 at 1:22pm

Hello Scott,

once again thank you for your quick reply. I will go through this links and some modules in which i can find views. I know it will take time but i will keep trying. If i get it working i will post it here.

Thank you
Tejas Mehta

But can the form data be edited?

Posted by malks on April 26, 2010 at 10:53pm

Hi,

Scott, that series from Steve Karsch is excellent, thanks for pointing it out.

Tejas, I still don't think either of the articles presented will get you to where you want to go. I had a similar requirement a while ago now and came across the editview project which had some of the functionality you require. I just found the editablefields project too which looks more promising and more active and sounds like it might be closer to what you want.

Look forward to hearing how you go.

Anth.

Context is everything. :-) I

Posted by scottprive on April 27, 2010 at 12:32am

Context is everything. :-)

I misread Tejas first post, and interpreted this as "data coming from forms". No, this is data which already exists, and now display it in editible forms (not explicitly stated, but implied by wanting to display checkboxes and radio buttons).

Basically you want Views to be both read and write to your database... you want submit forms that are as easy as Views is.

So I change my answer also, and it matches Anthony's suggestion. Investigate those 2 modules.

The alternatives to Tony's suggestions are to write forms API code to read in the data and set the textfield/etc values (Forms API is not difficult, but why write code if you can get a module to do it for you?)

Hello Scott and Anth, sorry

Posted by tejaspmehta on April 27, 2010 at 9:53am

Hello Scott and Anth,

sorry for late reply as i was busy with work.

@Scott : Your links are very good. It is nice tutorial for starter like me. It will help me a lot. but as Anth said in comment it is not leading me to development of view in which i can put my data in form manner.

@Anth : editview and editablefields both are good modules. I have yet not implemented it due to busy schedule but by reading description it looks that it might help me a lot, specially editablefields module.

I will be doing some research work with view based on this 2 modules and let you know my working status on this as soon as i can.

Thank you
Tejas Mehta

Hello Anth, Thank you for

Posted by tejaspmehta on April 28, 2010 at 10:18am

Hello Anth,

Thank you for providing link to editablefields module. Its nice module and saves lot of time. But this module has also limitation. If my user is not logged in say anonymous than we have to provide permission for each and every fields and than also it is not sure that it will work. But with views it works fine.

Now i am getting views module more than before i start so now i might have to ask same question in another manner.

When we add fields in view at that time there is a group selection box. Inside that Node, Taxonomy, Comments, Users are listed. Now if i enable module of ubercart than it will add Product in that group. I would like to know that how do i add new Groups in that ? also by which conditions this groups are coming in this select box ? They are listed because they are content type ? I want to add Attributes which is defined in database but it is not content type. Yes we can attach it like content type in product.

I hope my question is clear now. If not do let me know so i will put it with screen shot.

Is there any module or solution available for this type of problem ?

Thank you
Tejas Mehta

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /