i work with Symfony2 and I want to see how I can use Form Events to link two fields select type.
The first field contains the cities and the second contains the country.
here is my entities:
user
- id
- name
- IdCity
city
- id
- CityName
- IdCountry
country
- id
- countryName
And thank you.
Solution #1
( working without javascript , enhanced with javascript, no reload required, small city amounts )
Create one select field of entity field-type displaying all cities and use group_by to group by country.
hide your single grouped select field with javascript ( type="hidden" )
split the select fields with JavaScript into a country field for the groups and add a second one for cities
change the city field if the country fires onchange event
change the hidden field if the city field fires onchange event
This way you are saving the code necessary to create a second form, inject your current country, filter with a second queryBuilder ... If you do have a lot of cities ( even with a cached result you are outputing too many )... go for solution #2.
Solution #2
( huge amount of cities, therefore loading cities filtered by country selection required )
create a form with an entity field type for the countries
pass the currently selected country into your form - default to null ( i.e. from your action or inject the request and read it from there)
create a subform of entity field type for the cities
if the selected country read from request is null - don't add the subform to the builder
if present -> add the subform and use the queryBuilder city field-type to filter the cities by country
enhance by AJAX-loading the subform on country-select
Hope you get the idea :)
Related
Im Tyring do the following;
At Checkout page;
When a User Selects the State ( out of 3) below the City Dropdown must include the list of cities that are in the related state.
Eg:
State : Dubai
Cities to show : ABC
If State is Sharjah
Citiyes to show : XYZ
I tried using a Custom Feild editor and managed to get the functions.php updated with the list of one State but I can't figure out how to add the conditions, other stats, and Cities.
looking forward on a guide
Thanks
How can I default to populating the Select drop down list with a value, in this case it would be the country U.S.. We've removed other countries from the list but users are still required to select the one option.
In addition to a default value, the dependent fields would need to be populated. Currently in Intershop, selecting the country populates the State field. I would like to default to U.S. and have the State field already populated on the initial request, sans ajax calls.
You would have to modify some pipelines for this.
The webform it loads is based in the country code. Intershop gets the countrycode from the addressbo or as a parameter. See the ViewUserAccount-ChangeAddress : this pipeline is used in the ajax request to load the webform when u select a country. You could use the same logic to load the U.S webform (US) when the address has not been filled in yet.
Here is the scenario:
In the Sales and marketing > Sales orders > All sales orders
I entered the lines by double-clicking the Sales order number
by doing that I am entering the lines of the sales order.
Now in my lines, there is a button there where I will use to add a syntax where I will insert fields in my newly created table.
I would like to know how can I know what record I am in (before entering the lines/before double-clicking the sales order number). I need to know what Sales order number I'm in as I enter the lines of the record.
In every form the current record of a specific FormDataSource has the same name of the FormDataSource. For example in the SalesTableListPage form the only datasource is called "SalesTable", so the current sales order record is identified in your code with the salesTable identifier.
Every record is extended from [Common]. There you have field TableId. You can get table name with [tableId2name].
You can inspect fields with DictTable and field* methods.
let's say I have 2 drop down's and one displays the States list and another Occupation. Both are independent in this scenario.
On the database side, I've a user profile record with fields that saves "state_code" and "Occupation_desc"
The table that saves the state details will have two fields: state_desciption, state_code
The table that saves the state details will have two fields: Occupation_desc, id
When loading the profile, On binding the drop down control, I need to show the state name rather than the short-cut(I need to show California rather than "CA",
but db record will have "CA".)
sample code:
drpdwnstates.DataSource = //binding the results
Me.drpdwnstates.DataTextField = "state_desciption"
Me.drpdwnstates.DataValueField = "state_code"
Me.drpdwnstates.DataBind()
For example, if i'm loading a user profile from California, then i need to highlight/select the California in my dropdown.
Contract to this, other drop down will have the Occupation list need to show the description itself(description itself is saved in the user profile record, not id).
Any help on how to select the saved value on the load??
You can select an item by setting the selected value of the DropDownList:
drpdwnstates.SelectedValue = "CA";
If the state code is saved in the user profile, you may set the value this way:
drpdwnstates.SelectedValue = userProfile.StateCode;
You can adapt this code to the specific data structure of your user profiles.
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)}