Cannot empty categories field - craftcms

When trying to delete all the categories from the categories field, it doesn't do so and just brings back the old categories. But when you try and delete just one category from the categories field, it gets deleted.
Steps to reproduce
Create a categories field and assign values to it.
Create a form with checkboxes to allow you to delete and add categories into the
categories field.
Uncheck all checkboxes to empty out your categories field.
It will return with the previous value.

Related

Related tables, filters and conditions

I have a new table where one of his fields is related to Table Items. I want to place a filter in one of the function fields Item Category pointing register the Item table, but do not know how this dual role. I hope it was not too confusing ..

How to add multiple rows in a single table using single submit button

I am new to Ruby on Rails and don't know much about it. I want to add attribute_id and attribute_value_id from table Attribute and AttirbuteValue to third table CustomerOrder (id, attribute_id, attribute_value_id). A user can have multiple combination of attribute_id and attribute_value_id. I am looping all values of Attribute and AttributeValue to a customerOrder from and want to save all checked values to CustomerOrder table.

How to sort list after changing category in select_tag?

I used following answer to create list of categories in my view
create a list box in ruby on rails
and after choosing one of categories, I'd like to list below has elements from selected category. Every item of that list has field category_id. How can I realize it? Is any possibility to call from select_tag function in controller, for example?
You can use order to get your ordered list. If you want categories list in ascending order (according to their name), the following would do your work:
#categories = Category.all.order(:name)

Filemaker Pro display a name instead of id for multiple fields with the same relationship

I have a two color fields in my Product table. They both are IDs that map to the Color table with a description. I know the idea with Filemaker is to have 2 fields for this, one for display and one to hold the id. However, I can't get a display field to know which colorid to map with, and therefor nothing shows up.
It sounds like you might have your relationship defined with BOTH colorID fields connected to the Color Table. So there is only one relationship that is using two key fields. If that is what you have then, that is your problem.
To fix it, you will need two relationships. One for each Color ID field in your Products table. Name them something like "Product Color 1" and "Product Color 2". Then setup your two display calc fields to use those two relationships respectively.
I can't tell from your description what's missing in your setup, so let me describe what you should have:
Table Colors:
ColorID - a unique id field (preferably auto-entered serial number);
...more fields describing the color ...
Table Products:
... fields describing the product ...
ColorID1 - a Text or a Number field (match the type to Colors::ColorID); nothing auto-entered;
ColorID2 - same as ColorID1;
On the Relationships Graph, create two new occurrences of the Colors table and name them "Color1" and "Color2". Define the following two relationships:
Products::ColorID1 = Color1::ColorID
Products::ColorID2 = Color2::ColorID
Define a value list using the ColorID field from Colors, also showing [some field that helps to select the color]. Attach this list to the two ColorIDx fields on the Products layout.
Place some fields from the Color1 and Color2 occurrences onto the Products layout; make them non-enterable in Browse mode to prevent accidental modification.
Now, when you select a color in either of the two ColorIDx fields, the related fields you have placed on the layout will populate with data from the corresponding related records.
There are some assumptions being made here:
each product has exactly two colors;
it is important to know which color is #1 and which is #2 (otherwise
we could have used a single relationship and show the two colors in a two-row portal, in no particular order).

Rails: UI to add children from large record set to parent model in HABTM relationship

Given the parent / child HABTM relationship:
class List < ActiveRecord::Base
has_and_belongs_to_many :items
end
class Item < ActiveRecord::Base
has_and_belongs_to_many :lists
end
I need to set up a UI to add Items (children) to a List (parent) from the List create / edit form. The wrinkle is that there are far too many Items records to use checkboxes. An initial thought is to have a popup window that allows the user to browse the collection of Items to find the records to add, but I'm not sure how that would work with new List records (where the parent ID would not yet exist). I'm looking for a solution that will make it easy for the user to navigate the large collection of child records and add them to a parent record in an intuitive manner with the minimum amount of clicks required.
Users will need the ability to browse the Item records to find acceptable choices, so an auto-complete text box which would force users to search for records they want will not work in this case. The child Item records are organized with multiple attributes (e.g. title, author, genre, rating), so my original plan was to set up a table with the Item records with AJAX filter and sort to allow the user to narrow down the Item collection to the desired elements, and to then somehow add selected records to a List. Users do not need to be able to define new Item records while creating a list (i.e. when creating a List, the user will simply select multiple Items from the existing collection).
I like the auto-completing text-box for lookups like this; it'll depend on if your child-data set is intuitive enough for users to guess.

Resources