"Add more item button" to limited number of values - drupal

I have a scenario where in team leader enter his team members with their name and email id. I want to restrict team size to maximum of 10 team members. I am thinking of using Field Collection module to capture name and email values of team members. What I found is, this module provides "Add more item" button only if I select "Unlimited" in "Number of values" field for this collection. If I select "Number of values" to 10 it show 10 times "Name" and "Email". What I want is, it should show 1 set of "Name" and "Email" field, next to it should be "Add more" button which will show next "Name" and "Email" field set and so on till the count reaches 10(in my case).
Can any one help me with this or suggest me with some other module.
Thank you in advance..

Found solution to my question. Select "Unlimited" in "Number of values" field for field collection and written below code in hook_form_alter. It shows "Add more" 10 times.
if($form_id == 'form_id') {
if (isset($form['field_collection_name']['und']['#max_delta']) && $form['field_collection_name']['und']['#max_delta'] >= 10) {
unset($form['field_collection_name']['und']['add_more']);
}
}

Seems like this is a perfect scenario for the Webform Add More module. Unless you really need content types for this, would certainly recommend using the Webform. You may need to install the Webform module as a dependency for this which can allow you to quickly create forms you want for this purpose.

Another solution is to use the Custom Add Another module https://www.drupal.org/project/custom_add_another to customise the button text and the benefit is that you can have different text for the button per field per bundle.

Related

Conditionally loading multiple fields with multiselect with Caldera Forms for Wordpress

Good day,
I've been looking around for a solution to my problem, but could not find it documented anywhere. Feel free to link to another thread if useful.
I'm building a form on Wordpress using Caldera Forms. In this form, I have a multiselect dropdown for which each selection should show dynamically an extra field. Unfortunately, I cannot load more than one conditional field when selecting multiple values. It will only load the first field populated by the condition of my first selection.
Try it out:
Open https://34.95.27.135/test-caldera/
On the "Role" field, select "Software Engineer"
This should populate a "Top Skills" field
On the "Top Skills" field, if you autocomplete ANY of the options, the first condition is met and you will see the right field for it
Selecting more options from the "Top Skills" field should be populating other fields, but instead, it flicks in the view and then only shows the first met conditional field.
Anyone has had this issue? Was there anything special to do on the Conditions tab to make it work as intended?
You may Import this form by importing this JSON:
{"_last_updated":"Sun, 19 Jan 2020 23:23:23 +0000","ID":"CF5e213a11b5adc","cf_version":"1.8.9","name":"Career Matrix","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_97450":"1:1","fld_5750655":"1:1","fld_4465116":"1:1","fld_2852708":"1:1"},"structure":"12"},"fields":{"fld_97450":{"ID":"fld_97450","type":"filtered_select2","label":"Top Skills","slug":"your_top_skills_software_engineer","conditions":{"type":"con_9081220263929126"},"required":1,"caption":"Select your top skills.","config":{"custom_class":"","placeholder":"","multi":1,"color":"#5b9dd9","border":"#4b8dc9","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt2039319":{"calc_value":"x","value":"x","label":"x"},"opt2036344":{"calc_value":"y","value":"y","label":"y"},"opt2092176":{"calc_value":"z","value":"z","label":"z"}},"email_identifier":0,"personally_identifying":0}},"fld_4465116":{"ID":"fld_4465116","type":"star_rating","label":"z Proficiency","slug":"z_proficiency","conditions":{"type":"con_4202235771498248"},"caption":"Rate your z proficiency","config":{"custom_class":"","default":"","number":5,"type":"star","size":13,"space":3,"color":"#FFAA00","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}},"fld_2852708":{"ID":"fld_2852708","type":"star_rating","label":"y Proficiency","slug":"y_proficiency","conditions":{"type":"con_6383484066940033"},"caption":"Rate your y proficiency","config":{"custom_class":"","default":"","number":5,"type":"star","size":13,"space":3,"color":"#FFAA00","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}},"fld_5750655":{"ID":"fld_5750655","type":"star_rating","label":"x Proficiency","slug":"x_proficiency","conditions":{"type":"con_5108268722503233"},"caption":"Rate your x proficiency","config":{"custom_class":"","default":"","number":5,"type":"star","size":13,"space":3,"color":"#FFAA00","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"dube25#gmail.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Career Matrix","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_5108268722503233":{"id":"con_5108268722503233","name":"SE x Skill","type":"show","fields":{"cl6611176254177354":"fld_97450"},"group":{"rw1073423041345211":{"cl6611176254177354":{"parent":"rw1073423041345211","field":"fld_97450","compare":"is","value":"opt2039319"}}}},"con_6383484066940033":{"id":"con_6383484066940033","name":"SE y Skill","type":"show","fields":{"cl4932869345780543":"fld_97450"},"group":{"rw2445485636298987":{"cl4932869345780543":{"parent":"rw2445485636298987","field":"fld_97450","compare":"is","value":"opt2036344"}}}},"con_4202235771498248":{"id":"con_4202235771498248","name":"SE z Skill","type":"show","group":{"rw3854064841859657":{"cl7317560418250427":{"parent":"rw3854064841859657","field":"fld_97450","compare":"is","value":"opt2092176"}}},"fields":{"cl7317560418250427":"fld_97450"}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.8.9","db_id":"19","type":"primary"}
Thank you very much!

MS CRM 2013 Process Update Account - multiple values to one field

I'm trying to implement an update procedure like the one in this blog post (via extra entity and workflow updating account, triggered when the new entity is being created)
http://www.powerobjects.com/2013/08/01/updating-records-in-microsoft-dynamics-crm/
In my list and the new entity "Account Update" I have 3 fields for the full name of a company (name, name_2, name_3).
In my workflow I want to put these 3 together and combine their values in the Account field "Company" (the company's name).
In the process I tried to insert them via the "Form Assistant" and in the field "Company" I now have the following entry:
{Name(Account Update);Name_2(Account Update);Name_3(Account Update)}
but it doesn't seem to work. After my import and update of the account (which ends successful) the value in "Company" is only the value of the first name field.
Is it possible to combine values?
What exactly does it do, when I choose more than one field in the Form Assistant and say OK?
So at last I figured out how to archive it.
With the "Form Assistant" you can combine or add multiple field values to one new field but it is a bit tricky.
The value in the process update the properies have to look like this:
{Name(Account Update)} {Name_2(Account Update)} {Name_3(Account Update)}
BUT
It does not work if you enter this as text, you have to add the fields one after another so that they are recognized as fields (and marked yellow).
Click into the field (here: "Company").
Then choose the first field in the Form Assistant. Click "Add", choose it in the list below and click "OK". Now the field is in the field "Company".
Now go behind the end of the text in the field make a space and then choose and add the second field (clear the list in the Form Assistant before so that now only the second field is in the list)
So it's right if it looks like:
{Name(Account Update)} {Name_2(Account Update)}
Wrong if looks like following (happens when you keep the first field in the list before adding the second with "OK")
{Name(Account Update);Name_2(Account Update)}

Drupal 7: In Views, how could I order/sort in this manner?

Say for example I am printing name tags for thousands of content nodes in one content type called “Attendee.” Each of these nodes specifies a single "Attendee" for an event, (and their respective name tag). Say these attendees also needed name tags printed out for their “friends” who are attending with them. That is no problem—these “friends” obviously need their own node with the same fields to get their own name tag, so I distinguish that they are a “Friend of an Attendee” with a simple checkbox.
Now here’s the sorting order / grouping problem: When rendering the view, I need these “friends of attendees” to appear “right after” the attendee they are going with. Is there a way for me to maybe create a new autocomplete text field to link these together and then have them output next to each other?
p.s. I am technically using the Views PDF module, but it has the basic Views functions, so if it's possible with Views, it will probably be possible with this module.
In order to group these together, you have to have some way of linking friends to the attendees. You can do this by adding an entity reference field to the content type. See https://drupal.org/project/entityreference
here are the steps:
from admin/structure/types select "manage fields" on your content type
on the "manage fields" tab, click in "Add new field", and type in a label name. say "friend of"
for "type", select "Entity Reference", and for now, choose "Autocomplete" for your widget
click save
in the field edit tab:
select Target Type: Node
under Entity Selection, set Mode: Simple
set Target bundles: ( your attendees type )
click save
go to admin/config/development/performance and clear all caches
You should now see an autocomplete field when you edit an attendee that you can use to set the friend relationship
Things normally get a bit complicated now, as you have to tell views about the relationship between attendees and their friends. If you want to keep this dead easy, you can set the primary attendees as their own "friend" ( who they are going with ) so that you can group them together easily with their companions, without having to worry about contexts, relationships, or any other fancy stuff.

Combine 2 user profile fields to provide "Add More" to the whole field

I am trying to create a user profile field in drupal 7 that combines multiple fields and can have multiple values.
For Example,
the field is "Past Job Title" ,"From Year", "To Year" and the whole field ( having 3 sub fields ) can have multiple values thus can have values like
< "Google" , 2000, 2003 ><br/>
< "Facebook" , 2003, 2007 ><br/>
< "Xerox", 2007, 2009 ><br/>
The user should be able to add as many values he/she wants.
In Drupal 7, Multiple Values for a single field can be enabled by setting Number of Values to Unlimited, but how to do in case of multiple fields combined together.
Please Do Suggest...
I believe what you are looking for is the Field Collection module. It allows you to group fields together and allows the entering of many groups. The following article gives a good description of what the module does: Create Multigroups in Drupal 7 using Field Collections
From the Field Collection project page:
Provides a field-collection field, to which any number of fields can
be attached.
A field collection is internally represented as an entity, which is
embedded in the host entity. Thus, if desired field collections may be
viewed and edited separately too.
How can we validate each field collection entity?
Let me Explain:
I have used field collection in line item types.
Line Item type = People
Field collection fields are:
Title
First Name
Last Name etc
I have given the number of values: unlimited. That's why add another item button is appearing.
Now, if user entered values in one set and left others blank and then clicked on add to cart button then, how can stop him to continue further.

Creating a node to which users can add fields in Drupal 6

I would like users to be able to create multiple text fields and select "yes" or "no" on one of 3 options for that field.
For instance:
Text field = "24/7 support", option 1=(y/n), option 2=(y/n), option 3= (y/n)
Text field = "bon-bons", option 1=(y/n), option 2=(y/n), option 3= (y/n)
... with up to 25 text fields in that content type.
Does anyone have any idea how to accomplish that?
Basically I need to implement a system, where users can create and edit a "Features list" easily. then assign each one of those features to one of 3 packages.
Sounds like you want a grid field. I don't see how a text field would be useable for this at all.
1) First create a content type with 25 fields and the 3 options you mentioned.
* As per your post you mentioned you only want upto 25 posts .
2) Use jquery for displaying only one field and they can always click on a more link for additional fields.
If you don't know jquery and how to implement this then revert back.
Cheers,
Vishal

Resources