Skip Navigation

[Resolved] Multiple field "email" or "phone" : each instance associated to its proper owner

This thread is resolved. Here is a description of the problem and solution.

Problem:
One Post Type has 2 kind of repeatable Fields assigned.
You want to display the First repeating instance of Field A along line with the first repeating instance of Field B
(etc)
An example can be wpcf-name and wpcf-phone

Solution:
1. You set up 2 Repeatable Fields, "phone" and "name"
2. Pay attention that each item has a pendant, means, when you add a Phone go ahead and add a Name as well.
3. Once you populated this data, create a View and query the Post type in question.
4. In the Loop, use the Wizard to create a Table and use the below approach to insert your above created Fields:

<!-- wpv-loop-start -->
    <table width="100%">
        <tbody class="wpv-loop js-wpv-loop">
        <wpv-loop>
            <tr>
                <td>[types field="name" separator="<br>"][/types]</td>
                <td>[types field="phone" separator="<br>"][/types]</td>
            </tr>
        </wpv-loop>
        </tbody>
    </table>
    <!-- wpv-loop-end -->

5. Note the separator, it's a HTML break

<br>

to bring each instance of the same field on a new line.

You can also use or-each ShortCode and Item ShortCode.

Relevant Documentation:
https://toolset.com/documentation/user-guides/repeating-fields/#Displaying%20Repeating%20Fields
https://toolset.com/documentation/views-shortcodes/#wpv-for-each
https://toolset.com/documentation/views-shortcodes/#wpv-item

This support ticket is created 8 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 3 voices.

Last updated by PiotrO586 8 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#367485

Hello everyone, and thank you for creating the best WordPress Plugin Set ever, I cannot tell you how much I have learned in these past three years using Toolset, best money spent EVER!
I created a CPT called Companies that is designed to hold company data (Name, address, email, phone etc). There might be times when I don't have only one cell phone number or email, and I need to create multiple instances of that particular field. Right now I can do that but I would find myself having a bunch of cell phone numbers not knowing who's going to answer, because I don't have a way to store the name of their respective owner.
I would like to know if there is a way to achieve this without having to create a whole new CPT and build a relation to Companies. Thanks in advance for your help!

#367536
Front End Output.png
Post Edit.png

It's not so easy to "give meanings" to repeatable fields, I know that.

It depends on how you display your data, but a possibility (actually one of the only which is easy and makes sense) is to display it in a View with a Table Grid.

You set up 2 Repeatable Fields, "phone" and "name"
Pay attention that each item has a pendant, means, when you add a Phone go ahead and add a Name as well.

See my screenshot on how I mean this to be setup in the Post Admin screen.

Once you populated this data, create a View and query the Post type in question.
In the Loop, use the Wizard to create a Table and use the below approach to insert your above created Fields:

<!-- wpv-loop-start -->
	<table width="100%">
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				<td>[types field="name" separator="<br>"][/types]</td>
				<td>[types field="phone" separator="<br>"][/types]</td>
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->

Note the separator, it's a HTML break <br> to bring each instance of the same field on a new line.
https://toolset.com/documentation/user-guides/repeating-fields/#Displaying%20Repeating%20Fields

See how this looks on the Front End in the screenshot as well

You could also play with the for-each ShortCode and Item ShortCode:
https://toolset.com/documentation/views-shortcodes/#wpv-for-each
https://toolset.com/documentation/views-shortcodes/#wpv-item

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you, I look forward to your reply!

Thank you for your patience.

#368409

Thank you so much for your help, Beda. The solution you suggested is, in my opinion, preferable if you're sure that the data entry phase is assigned to someone who actually is not a complete novice. In my case I have collegues that have little or no knowledge of computer, and I won't be there to assist them when they enter data, as this should be an individual job... so in the end I am not completely sure that data would be consistent. Maybe this could be a new feature that you guys can work on in future releases? I am going to try it, nevertheless... and see what happens! Thank you again!

#616043

I would also see the need for multicolumn repeating fields, but to be able to define separate header for each column (something I use in Gravity Forms).
Example usage, anything with first, last name and some other data or a file with its label.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.