Can we use field collection in localized fields or vice versa. As while going through pimcore 4 document
https://www.pimcore.org/wiki/display/PIMCORE4/Structured+Data+Fields+-+Fieldcollections
I found below statement
If you want to use localized fields inside field collections you have to set the object before calling any localized field - related methods.
But when I tried I was not able to either add field collection in localized field nor vice versa.
Thanks
You can't use field collections inside localized fields. But you can use localized fields inside field collections.
The following example hopefully explains it better.
So this will not work:
Object
-> Localized fields
-> Product name
-> Product description
-> Technical data (field collection)
-> Value
-> Unit
But this will:
Object
-> Localized fields
-> Product name
-> Product description
-> Technical data (field collection)
-> Localized Fields
-> Value
-> Unit
The statement you are citing is referring to adding field collections programmatically.
Related
Scenario :
I have a list of items. This list has columns with text value information(lets say Val1, Val2, Val3,..) and links which will take the user to the other pages. One of these fields is a URL column (type - hyperlink) which acts as a filter. On clicking the URL, it directs to another page and filters the page for each specific value(for e.g Val1) from the parent page.
So to achieve this,
- I created a new workflow in SP Designer 2013,
- Created a workflow variable of type String (lets say **'WFVar1'**) and added to Action ‘Set Workflow Variable’
- For the ‘value’ in the action I clicked the 3 dots (…) on the right, I set the URL for e.g
https://abc.xyx.com/thisisanexample.aspx and then clicked on Add or
Change Lookup and set the field from Source as Val1. The return
field automatically fills up *"As String"*. The URL is now followed
by Val1.
- Once done with the URL and description, I added the workflow Action ‘Set Field in Current Item'
- I clicked ‘field’ in the Action and choose the hyperlink field(URL) of the list.
Here comes the issue :
I click the ‘value’ in the Action and choose ‘workflow Variable and
Parameters’ and select the variable WFVar1. The return field
automatically gets set to "As Dictionary from JSON" instead of
"As String".
Due to the type difference, the workflow doesn't work and remains suspended.
Need help!!
URL fields do contain multiple string values for the URL and text description.
Since the return type is a dictionary, you may need to store it into a dictionary variable and then extract out the text and URL into separate string variable for later use.
If you need to know what the fields in the JSON are, you can save the dictionary to a string variable and write it out to the log if the JSON string is less than 250 characters, else it will also lock up and in that case you can write the value to a multi-line text field in a list which has a length limit of 64k characters.
i'm searching for a strategy to create a one to many raltionship in ZF2, between two tables using TableGateways. Table one is called "workers" and one worker has many "departments".
Now i want to have a form for the workers which inlcudes a special DepartmentFieldset (Textfield to enter an ID).
I was thinking about this way:
The worker Model has one more type array for the departmentIDs, but there is no field in the table for the departmentIDs. Also there is a getter and setter for this field.
EDIT Action:
In the editAction() of the workers TableGateway, i have to fill the normal form + the form collection for the IDs, so i need data from both tables.
$worker = $this -> getWorkerTable() -> getWorker($id);
$departments = $this -> getDepartmentWorkerTable() -> getDepartments($id);
$worker -> setDepartmentIds($departments);
What type must the departmentIDs field in the worker Model be, that i now can use
$form = new WorkerForm();
$form -> bind($worker);
?
Let's now asume, data is posted and validated (Validation is set with the getInputFilter() in my Model). I want to save all the data:
$this -> getWorkerTable() -> saveWorker($worker);
$this -> getDepartmentWorkerTable() -> saveDepartments($worker);
Is that the right way to do it?
I think if this would work, the ADDAction is not the problem.
So the main questions are:
How can i set up a Model to handle one to many relationships? How must the exchangeArray() function be written?
How can i fill up a Form with ElementCollections with the Data from the Many Realtionship Table?
I think the main problem is, how to use an entity filled by the TableGateway which additionally contains an extra field for the relationship.
Some valuable tips would be great!
Regards, Yuri
I have a form with a field named description that can be either a text box or a select list depending on the input of previous form fields. How this works is if the values of the previous fields are a common scenario, we populate the description field as a select list with values stored in the database. If there are no matching scenarios in the database the user is allowed to type in their own description.
If the input type is a select list the submitted value is an integer (in string form) that can be used to query the database to get the description from the database. Otherwise we just use the text value submitted via the text box.
My question is: Once the form is submitted is there any way of determining the input type of the description field?
In my controller I was hoping to do something like this:
if(InputType == "SelectList")
{
Description = model.Description;
}
else if (InputType == "TextBox")
{
Description = GetDescriptionFromDB(model.Description);
}
I have considered checking to see if the description field parses to an integer, but that will not work if the user types in an integer to the text box. This is an internal app used by trained people who are not likely to enter junk values, but I still don't like to use logic that is dependent on what the user types in. I have also considered using Javascript and a hidden field to pass along the input type, but I was hoping for a cleaner solution.
I am currently using modelbinding to get my submitted form values, but am open to other approaches.
Edit:
People are suggesting alternate approaches, most of which I have already considered. What I really want to know is whether information regarding input types are passed to the server when a form is posted or just data.
Why not just add a hidden field to the form that would track what type of input the description field is:
if(InputType == "SelectList")
{
DescriptionInput = MyEnum.SelectList;
Description = model.Description;
}
else if (InputType == "TextBox")
{
DescriptionInput = MyEnum.TextBox;
Description = GetDescriptionFromDB(model.Description);
}
<select name="sel">
<option class="default">Default</option>
</select>
Every Html Form Element in the form submit to server it's take it's value to server. If you choose the select then it's value are off-course going to server.
You just need to parse it and it will work.
If there are no matching scenarios in the database the user is allowed to type in their own description
I thing Queti's answer is correct. You can use hidden field and pass the ID of existing matching field.
Remember that this is unsafe so better option is you can check them on server too that is their anything exist in server or not. This way your code are sure for what input he make from user.
I am using a LinkedList of a very simple custom class I created to fill the select statement. I got everything set properly (values and keys), but I can not load my default value.
This is the code I used for my select statement:
<s:select name="reports" list="filters" listKey="id" listValue="name" value="%{filterName}" onchange="filterResults(this.options[this.selectedIndex].text,this.options[this.selectedIndex].value)"/>
The filters list that is used has an id field (Integer) and a name field (String).
I know that the value in filterName should match with a value in the drop down list. I printed it to the screen with a property tag, but nothing is selected when the page loads. Any help is much obliged.
I am new t struts2. i built one page, that shows list of employees. I can seach the employes based on his name by applying filter criteria and click on find button. At the same time, i provided check box in the left side for each employee name for delete operation. for all checkboxes, i gave Integer[] attribute name which is declared in Custom Actionclass.deleteaction is working fine. But when i click Find button the action is not getting submitted. Then i changed Integer[] to String[] both functions are working fine. What will be the problem? is it something like, attributes should only be String type.
The cause of your problem is that the Struts2 checkbox sets a boolean property on the action class:
Struts 2 Form Tags: Checkbox
When you defined the checkboxes as an Integers, the framework couldn't covert the boolean to an Integer. However it was able to convert the boolean to Strings. If you check the results in your action class, you should see the String[] populated with "true" and "false".
In general Struts2 is pretty good at converting submitted form data to whatever object type you want. Check out the docs on type conversion for more info.