Dear helpers and saviors !
I'm trying to create some dynamic forms with Silex.
My objective is to have the user create a state in a existing country. I would like him/her to select a region (like Asia, Europe, America...), then select a country to which link the newly created state.
I have some "classic" and simple forms extending AbstractType, in which the user can select the country directly. I created a choice list based on a call to a DAO (database) to find all available countries. I would like to add a region choice_list field to reduce the number of available country (and reduce the database charge as well even if it isn't my main goal).
I've seen http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html#cookbook-form-events-submitted-data, but it seem that we can't create subform for elements that are "parents" of the main class (or that i did not understood how), saying that the link is not stored in my object i would like to create. What i would like to do here is to add a field for the 2-level above (state->country->region), not direcly linked (a state have a country, and a country have a region) region.
I do not manage to imagine or code it properly, or even simply displaying.
Please note that i'll have to do it on several levels (state, city, and some other classes), and i would like to find a quite generic way to do it (understand not a ready solution for this particular example).
Any ideas ?
Please excuse my english, and thank you very much for your help !
For reference, here are my DB links between objects :
Region : ID and Name
Country : Codes, ID, Name and link to Region's ID
State : Codes, ID, Name and link to Country's ID
City : Name, ID and link to State's ID
I managed to do what i wanted.
I created supplementary forms, asking for filling each of the "parent" objects.
So in addition to my Types forms, i now have a selection a Select forms, allowing me to select Region, then Country, then State.
Related
Is it possible to reference additional columns apart from the 'Code' and 'Name' columns when using a domain attribute in an entity?
E.g. A person entity has a code of '1' and a name of 'Smith' and a Gender of 'Male'
In a customer entity there is a domain value referencing the person entity which displays the following 1 {Smith}. The users would like an additional read only attribute which would copy the Gender value of 'Male' into the customer entity based on the domain value. Can this be done using out of the box MDS UI?
I know this is duplicate data and breaks normal form but for usability this would be useful. It would be the equivalent of referencing additional columns in an MS Access drop down list.
Many thanks in advance for any help
This is not possible with the standard UI. One option would be to develop a custom UI where you can handle these kind of requests.
If you want to stick with the standard product I can see a workaround but this is a bit of a "dirty" one.
You can misuse (abuse) the Name attribute of the Person entity by adding a business rule to the Person entity that generates the content of the Name attribute as a concatenation of multiple attributes. You of course need an additional attribute that serves as a place holder for the original Name. The concatenated field will then show in your customer entity.
One question that does come to mind is why a user would like/need to see the gender of a person in a customer list? As you have a separate Person entity I expect you to have multiple persons per customers. What would the gender of one person - even if it is the main contact - matter?
I want to implement Schema.org for bid announcements and I'm a bit confused since there is no available type for it.
I have the following fields associated with it:
title
date of announced
closing date and time
body (announcement content)
organization name
organization address
categories in which the announcement belongs
For call for bids, you can use Schema.org’s Demand type.
There is no property for the full text (if it’s not too complex/long, you could use the description property) or for the categories.
You can use the seeks property (with the Organization as domain) and/or the seller property (with the Demand as domain) to point to the Organization that has the demand.
The objective:
Having a many-to-many relation be displayed as a dynamic list of select inputs(single choice dropdown list)
User arrives on page with a single select field (multiple = false) populated with persisted entities and add/remove buttons. By clicking the add button, a new select field with the same options appears below the first, which adds a new entry in the M2M relation. By clicking remove the field disappears and the entry should be removed.
The model:
Two entities: User & Manager. A User has exactly one "special" Manager and unlimited normal Managers.
Managers manage unlimited users.To model this I have created two relationships for which the user is the "owner" (not sure how to translate this)
ManyToOne specialManager
ManyToMany normalManagers
I haven't created a many to many relationship with attribute "special" because the requirement is exactly one special manager and I wasn't sure if Symfony/Doctrine would cause problems down the line.
What I have:
I can display a multiple select field with the existing entities using Entity field type, as per the documentation. Functionally this is what I need, visually it is not.
I can also use the Collection field type to display a single text field, and add or remove more with JS, as per the documentation. Visually this is what I need, but The text fields (entity attribute) need to be replaced by choice field.
The question:
Before I continue digging, is there a simple way to achieve this list of select tags?
For anyone else who may eventually need a dynamic list of select fields:
I initially solved this issue by detaching the field(s) in event listeners, and handling the display/submission manually in the controller.
However I wasn't satisfied with this clunky solution and when I encountered the same need I used a second solution: creating an intermediary entity xxxChoice (in this case ManagerChoice) which is Mto1 inversed related to User and Mto1 related to Manager. Then by creating a ManagerChoiceType form with "Manager" entity field type I was able to easily display my collection of dropdown select lists.
Background
I was given the task of writing a Small Business online database. This database is to include a lot of info as well as info on their directors and branches. Since any business can have an unlimited amount of directors and branches, I need to create a database that is not limited to just one director and/or branch.
What do I have
Currently I have 3 tables.
smmes [id, company_name, trading_name, business_address, registration_number, tax_reference, vat_number, bbbee_status, employees, awards, created, modified]
ownerships [id, smme_id, name, surname, gender, age, race, disability, qualification, created, modified]
branches [id, smme_id, location, contact_number, contact_person, created, modified]
Note: smme_id is the id of the company in smmes that the branch or director belongs to.
And I have a view for the SMME's.
What is my question
I'm VERY new to cakePHP (in fact, this is my first app I'm creating with cakePHP). I want to know how I can make one form where a user can enter all this detail and then add the details for all directors and branches from one view. I would prefer that they do not have various views to go through to create all the details. Add to that, this one view should then save all the data to the correct tables with the correct smme_id.
Is this possible or should I rather leave cakePHP and write it manually.
You can load model on demand in your controller and then pass model specific data(received from posted form) to loaded model's save method.
public function detail(){
if($this->request->is('post')): // update only when form is posted
$this->loadModel('ownerships');
$owner_name= $this->request->data['Ownername'];
$ownerships_data = array('Ownership' = > array(
'name' = > $owner_name
//add other keys from posted form
)
);
$this->Ownership->saveAll($ownerships_data);
// load other models for saving posted data in related tables
endif;
}
Similarly load other models and pass fields from posted form as array to it's save method.
Suppose URL format is http://example.com/director/detail.So you would like to put above method(termed as action in MVC terminology) in app/controllers/directors_controller.php
Generally if URL format is http://somesite.com/abc/xyz it will look for xyz action in
app/controllers/abcs_controller.php
You can read more about cake conventions here
The iPhone Contacts app has a nice interface for saving addresses. When you change the country, the fields change to be specific to that country's address fields. For example, the US has a "Zip" field, where other countries have a "Postal Code".
Is there any method to get these fields, possibly by passing a country code?
I think what you are looking for is ABCreateStringWithAddressDictionary method of ABAddressFormatting class. Here is the link to the ABAddressFormatting Class reference