How to enable more options for a DropDown Field in Silverstripe - silverstripe

I have a SilverStripe DropDown field, with CountryID:
DropDownField::create('CountryID', 'Country', Country::get()->map('ID', 'Name')->toArray())
The field is not showing the dropdown, instead it shows an input field with the ID in it and the text: "Too many related objects; fallback field in use"
How can I disable the fallback from happening. For eg, can I set the maximum number of related objects to a higer number, say 300?

It is setable like this:
// mysite.yml
SilverStripe\ORM\FieldType\DBForeignKey:
dropdown_field_threshold: 300

Related

MS Access: Count selected items in multi-valued field on a form

I have a Microsoft Access form with a multi-valued field. I'd like to display the number of items a user has selected to the right of that field. The field is called [Description]. The control displaying in red is =Count([Description]). It counts how many options there are in the [Description] field as opposed to how many have been selected. Any thoughts on how I can just count selected items?
It turns out that if my form is filtered for a single record, the formula works - it shows the number of items that are flagged in the Description field for that record.
If my form is not filtered (even though its 'Default View' property is set to 'Single Form'), it shows the total number of possible options in the Description field.
Very strange behaviour indeed.

How do you count the number of lists/records selected on a multiselect field in NetSuite?

I have a couple multiselect fields in NetSuite where you can pick from a list of customers.
I would like to run a saved search that counts the number of customers selected on the multiselect field.
If I use count in a summary search it says 1 even if there's more than one selected (because it's the same record)
Any ideas how to go about this?
I see some case when examples for counting, but they don't seem to apply to multiselect fields.
Thanks
The saved search interface should provide you with a drill down for fields in record. These selections are consolidated at the 'bottom' of the field list and are suffixed with 'Fields...'
On the Results tab of the search definition, select a new line and under the 'Field' column, click into the dropdown and find the line that matches your custom multiselect field with the suffix 'Fields...' So if your custom field is 'My Customer List', look for 'My Customer List Fields...'
This will open a new popup, with a new field list derived from the backing record type(in this case 'customer'). You probably want to just use 'internal id' since it's guaranteed to be unique.
Your 'Field' will now say something like: My Customer List:Internal ID
Now your summary type of 'Count' will accurately tally the unique customers.

"Add more item button" to limited number of values

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.

How to edit an Array field in "Sonata Admin" with Symfony2

With Symfony2, i use "FOSuserBundle". In my Entity "Group", i have an array column named "roles". this is "ArrayCollection" type. How to edit this field "roles" with Admin Generator like "Sonata Admin" when i want to create or edit "Group".
I try with "sonata_type_collection" type but no success.
Do you have an example or link who explain how to do this ?
PS: "roles" use "DC2Type:array" in Group table with MySQL.
WARNING EDIT: I'm not using Sonata anymore, #romain-bruckert comment might be better.
I think that you need to rely on the SonataAdmin field types :
array: display value from an array
boolean: display a green or red picture dependant on the boolean value, this type accepts an editable parameter to edit the
value from within the list or the show actions
date: display a formatted date. Accepts an optional format parameter
datetime: display a formatted date and time. Accepts an optional format parameter
text: display a text
trans: translate the value with a provided catalogue option
string: display a text
decimal: display a number
currency: display a number with a provided currency option
percent: display a percentage
choice: uses the given value as index for the choices array and displays (and optionally translates) the matching value
url: display a link
So for your ArrayCollection, an array type might be good.

Drupal 7 Views 3: Exposed Filters that search specific FIELDS

I'd really appreciate some help with this.
I'm trying to create two different exposed filters in Views. I currently have 6,000 nodes with 75 fields each inside one content type. I'm using a Page View with an exposed form in a block. I also have the Better Exposed Filters module installed.
The first one, I want to make a text box for searching terms, but have it only search my specified fields. I would have it search 3 fields (to do a search on the full name): First Name, Middle Name, Last Name. They are all in different fields. The only thing I've been able to make it search so far is EVERY TERM in a content type (where it searches every field, not just name). I did that by exposing this filter:
Search: Search Terms
The terms to search for.
The next filter I am trying to do is for the field "Graduation Class." It might be best to do search terms for this too (if I can figure out how to search ONE field, like above), but I was hoping to have a select dropdown that lists every Graduation Class. These classes in this field range from 1905-1972. When you click a year in this box, it filters the current results by that year.
This sounds pretty basic, but I can't seem to get it and would REALLY appreciate some help.
For your reference (if needed), here are the types of filters I can add. (Off topic: I'm actually not so sure what the ":format" ones exactly are). For the "Content:" filters, I'll only show the "Name" ones, because there are 73 others. Many of these filters are from the Feeds module, because that's what I used to import my nodes:
Content: First Name (field_cinfo_fname)
Appears in: node:cadet.
Content: First Name (field_cinfo_fname:format)
Appears in: node:cadet.
Content: Middle Name (field_cinfo_mname)
Appears in: node:cadet.
Content: Middle Name (field_cinfo_mname:format)
Appears in: node:cadet.
Content: Last Name (field_cinfo_lname)
Appears in: node:cadet.
Content: Last Name (field_cinfo_lname:format)
Appears in: node:cadet.
Content access: Access
Filter for content by view access. Not necessary if you are using node as your base table.
Content revision: Log message
The log message entered when the revision was created.
Content revision: Title
The content title.
Content revision: Updated date
The date the node was last updated.
Content revision: Vid
The revision ID of the content revision.
Feeds item: Import date
Filter on a Feeds Item's import date field.
Feeds item: Item GUID
Filter on a Feeds Item's GUID field.
Feeds item: Item URL
Filter on a Feeds Item's URL field.
Feeds item: Owner feed nid
Filter on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.
Feeds log: Feed node id
Filter on a Feeds Source's feed_nid field.
Feeds log: Importer id
Filter on an importer id.
Feeds log: Log time
The time of the event.
Feeds log: Request time
The time of the page request of an event.
Feeds log: Severity
Filter on the severity of a log message.
Feeds source: Feed node id
Filter on a Feeds Source's feed_nid field.
File Usage: Entity type
The type of entity that is related to the file.
File Usage: Module
The module managing this file relationship.
File Usage: Use count
The number of times the file is used by this entity.
Page Title: Title
A Page Title alternative to the Node: Title field.
Search: Links from
Other nodes that are linked from the node.
Search: Links to
Other nodes that link to the node.
Search: Search Terms
The terms to search for.
I might be mid-understanding you but don't you want to use:
Content: First Name (field_cinfo_fname)
Content: Middle Name (field_cinfo_mname)
Content: Last Name (field_cinfo_lname)
as your filters?
I'm guessing your fields are text areas which is why you've got the :format options; 'format' is another column in the longtext field type so will be available (just like 'alt' and 'title' would be available for an image field type).
If I understand the question correctly, you've got three name fields and you want a single text box to search all three fields. The easiest way to do this is to combine those three fields into a single field that is not displayed but can be searched using an exposed filter. One option is to use the Auto Nodetitle module to make the node title a combination of the three names. (I do this a lot with personnel directories so that a given entry displays as Lastname, Firstname). Then you could search on a the node title in your exposed filter.
If using the title is not an option for your project, you could add another field to your content type, eg: full_name, and write a small module to implement hook_node_save that would simply fill in the full_name field with "first middle last" whenever a node is saved. Then remove the full_name field from the display and use it for your exposed filter.
re: graduation year: If you're using a "List (Integer)" field type, that should be no problem. If you're using a plain text field type, that makes things more difficult. If you are using plain text, you may want to redo the field so that you could do cool filters such as "graduated before 1950" type filters or using jQuery sliders to select a range of graduation years.
Hope that helps.

Resources