By chinchunarayan on
Hi, i have a form which displays customer list.I want to include a select list with values (accept and reject) and a submit button on each row of a view output .I want to select one of the values and according to that the status must be update in database. How can i do that. Pls help.Is it possible to submit a form in View output. If so pls explain with some sample code.
Thanks in advance
Chinchu
Comments
Hi, what you want to do
Hi,
what you want to do can be done with a theme on the form. Actually, because you have forms elements in a list, the whole list is a form. So, the idea is simple: assign a theme to your form, and in that theme you manually render the input elements (select and submit buttons) and also the information in your list. To do that, you will have to set the customer information also in the form array that you create with your form constructor. A short example: suppose that this is your form constructor:
function mymodule_customer_list_form($form_state = array(), $other_customer_data){
//pseudocode:
foreach $other_customer_data {
1. declare the form elements for this customer
2. generate the view for this customer.
}
//other code here.
}
function theme_mymodule_customer_list_form($form){
//pseudocode:
foreach $form['customer_list_details']{
render the view of the customer and also the form elements. Form elements are rendered with drupal_render() : http://api.drupal.org/api/function/drupal_render/6
}
//don't forget to render the form_token and form_build_id!, because else your form will not be submitted.
}
If you give me your code, I can write some more specific information. Also, don't forget to implement hook_theme in your module and declare your theme function for your form there.
Vasi.
Thnx Vasi that was cool
Thnx Vasi that was cool