How to Store attributes as key value Pair in yii2 - yii2

I need to store attributes for the product as dynamic attributes.For eg color,type,amount fields are dynamic fields which is added by admin.Its stored under attributes table.
I want to add a product based on this dynamic attributes. Any Idea to do this in Yii2. I think its possible with loadmultiple feature of yii2. Any Idea.. Pls help.

I'll create a table 'attributes' related to 'products' table.
In the 'attributes' table I'll put 2 fields: type and value.
Type could be 'color', 'type', 'amount', ...
Value could be 'red', 'small', '10.34', ...
Then You should manipulate value based on type.

Related

How do I set a default value for a combo box that draws values from a table/query?

Since I'm new to Access but it is what I have available, I am customizing a database template to fit my needs. The template came with a table called "Donations" that records all the received money from contributors. I have added another table called "Descriptions" that has labels for the common types of contributions we receive (Donation, Participant, Sponsor, Anonymous, Memorial, Honorarium).
In the "Donation" table I have added a combo box called "Label" that imports the values from "Description" to populate the list.
SELECT Descriptions.ID, Descriptions.Label
FROM Descriptions ORDER BY Descriptions.[Label];
This lookup is working correctly.
Since most of the contributions we receive fall under the Description/Label of Donation, in the name of efficiency, I would like to set this to be the default value. However, I have no idea how to do this.
Failed Methods:
"Donation" - Error 'Type mismatch' in the default value.
[Donation] - Could not find field "Donation"
[Description].[Label] - Could not find field "Description].[Label".
Since your lookup query SELECT Descriptions.ID, Descriptions.Label includes the ID, I assume the ID is what is internally stored.
Open your Descriptions table, find the ID of "Donation", and use that number as Default value in the main table.

How to retrieve id's and names of all fields of a particular type from html to Django views

I have a html form with a list of input fields with id's, names and values. Is there a way I can get these values in Django views by only mentioning the input type. For example : get the id's and values of all input elements with type text.

Howcan I change the visible name of a many2many field?

I am using Odoo8.
I have two models: x_items and project.task.work.
I have a field called name and a custom field called x_wo_ref in the project.task.work.
I have a many2many field x_item_wo in the model x_items which is related with the model project.task.work.
Currently when I fill the field x_item_wo, the field name from project.task.work is showed.
How can I customise it in order to use the field x_wo_ref instead of the default field name for this many2many field?
Thank you
You need to define the _rec_name attribute of the model. _rec_name takes as default the field name and if this does not exist it does not take anything unless you specify it. For instance if you need to see the field phone you must write:
_rec_name = 'phone'
In case you want a _rec_name depending on anything you need to change the function name_get(). You can see examples in other models.

MS ACCESS - Adding items to Lookup Tables from a Master Query

A seemingly simple question that has me stumped.
I have a table [Inventory] with the following fields: [Category], [ItemName], [Price].
ex: "Plumbing", "ACME Showerhead", $43
I have a table [Categories] with the fields [Category], [SubCategory]
ex. "Plumbing", "Hardware" or
ex. "Flooring", "Wood"
I wish to have a form (ideally a standard grid) that allows me to enter new Inventory Records.
On this form would be the fields Inventory.Category, Categories.SubCategory, ItemName, Price.
When navigating to the field Inventory.Category, a drop down should allow me to select from Unique Categories.Category values. Once selected, the Subcategory field should allow me to select from valid subcategories of that Categories.Category. For example, if I chose "Plumbing" in the category field, I would only be presented with teh subcategory "Hardware" and not the subcategory "Wood".
I would also like the ability to add new Category Records while in this form, so I am not limited to whats in the dropdown. So for example, when adding a record to Inventory, if I want to create a new Category/SubCategory pair of say, "Plumbing", "Pipes", I should be able to do that without having to switch to another form/table or whatever.

Using a list parameter in SSRS

I need to be able to set an SSRS parameter to contain multiple values.
In TSQL, I can have a where clause that states:
where Attribute in ('Value1', 'Value', 'Value3')
What I need is in SSRS to have:
where Attribute in (#Attribute)
Where I am getting hung up is how to format the parameter value expression so that SQL sees it as: 'Value1', 'Value', 'Value3'
I have had some luck making the where clause look at only the first value, but I need it to look at all 3. How would I format the expression to do that?
I would just allow it to accept multiple values, and check each value individually, but I need the drop down list to have groups. So, if the user selects GroupA, the where clause uses: IN ('Value1', Value2') and if the user selects GroupB, the where clause uses a different list for the IN.
Hopefully it's just a matter of formatting the expression correctly.
Well, if you didn't have the requirements about groups, this wouldn't be an issue since all you need is to make your parameter a multi-valued one, and on your dataset query do WHERE Attribute in (#Attribute). But taking that requirement into account, the only way I can think of, is to have two multi-valued parameters: #Group and #Attribute. You'll need to make #Attribute not visible and create a dataset to populate it. That dataset would be something like this:
SELECT Attribute
FROM Attributes
WHERE Group IN (#Group)
And create another dataset for your report data:
SELECT <all your data>
FROM YourTable
WHERE Attribute IN (#Attribute)