Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I have been stuck with this issue for past several weeks.
The php field only returns Webforms sid instead of the value itself.
I tried $data->field_field as well but it returns empty. I guess for webform components it should be something else.
I have this:
$row->value_5: TimeIn
$row->value_6: TimeOut
in my available variables.
Please help.
Thanks
Comments
Comment #2
dev16.addweb CreditAttribution: dev16.addweb at AddWeb Solution Pvt. Ltd. commentedPlease perform below steps to return value of webform components using view php:
1. Create webform content view.
2. Add 'Content:Nid' field in field section and check 'Exclude from display'.
3. Add 'Content: Webform submission' field in Relationship section.
4. Add ' Webform submissions: Sid' field in field section and check 'Exclude from display'.
5. Now add 'Globle:PHP' field and return follwing code in Value code.
6. And return follwing code in Output code.
Hope this helps you.
Thanks!
Comment #3
maryam.naji68@gmail.com CreditAttribution: maryam.naji68@gmail.com commentedHi Tejal,
Thank you for your complete response. Very very interesting way of thinking.
But when I do the steps I get this:
date:please_let_us_know_how_your_day_was_with_the_client:
date:please_let_us_know_how_your_day_was_with_the_client:
date:please_let_us_know_how_your_day_was_with_the_client:
date:please_let_us_know_how_your_day_was_with_the_client:was_a_prn_given_today:if_prn_was_given_today_when_was_it_given
date:please_let_us_know_how_your_day_was_with_the_client:was_a_prn_given_today:if_prn_was_given_today_when_was_it_given
date:please_let_us_know_how_your_day_was_with_the_client:was_a_prn_given_today:if_prn_was_given_today_when_was_it_given
Which are the field keys of all components of all webforms!
It doesn't return any value and I think we need another relationship to specify the very webform node we want the submissions from. But I don't know how?!
Comment #4
dev16.addweb CreditAttribution: dev16.addweb at AddWeb Solution Pvt. Ltd. commentedOh yes! Apologies! One correction into the code for 6th point. Please find the updated code below:
6. And return following code in Output code.
Hope this helps.
Thanks!
Comment #5
maryam.naji68@gmail.com CreditAttribution: maryam.naji68@gmail.com commentedWorked Great, Thanks sooooo much!
You open so many new doors for me and my husband :D
I added a part to output the duration for me which is:
$time1= strtotime($fields["time_in"]);
$time2= strtotime($fields["time_out"]);
$duration=($time2-$time1)/3600;
print $duration;
Thanks
Comment #6
maryam.naji68@gmail.com CreditAttribution: maryam.naji68@gmail.com commentedComment #7
dev16.addweb CreditAttribution: dev16.addweb at AddWeb Solution Pvt. Ltd. commentedMy Pleasure! Good to hear this. Feel free to contact me in future for any Drupal related work. Always ready to help :)
Thanks
Tejal
Comment #8
maryam.naji68@gmail.com CreditAttribution: maryam.naji68@gmail.com commentedHi Tejal,
Now I need to get a percentage of each submission out of all.
So as you helped me I ended up with this code to calculate time duration for each submission:
Now I need to calculate a percentage like this:
$percentage=$duration/$total * 100;
But I dont know how to calculate $total and where to put the foreach loop!
I tried so hard to find it out myself but it didn't work.
I so much appreciate your help, thanks
Comment #9
maryam.naji68@gmail.com CreditAttribution: maryam.naji68@gmail.com commentedCredit provided to tejal.patel for providing my solution.
Many thanks!