How to add an autocomplete field in forms Symfony2? - forms

Actually, I can assign a task to a user in the edition task. I display a dropdown list of all user in the system when I edit a task. Now, I would to be able to display a text input with autocomplete for user, and be able to add user if is not exist.
How to do that?
Thanks in advance.

Two things you need to do:
1) Create a Data Transformer
hich will let you use an input field instead of the default dropdown to the linked entity.
The Data Transformer basically transforms your input (in your case a username string) to actual user object that you can store with your entity. It will let you define an input field instead of the default dropdown to the linked entity. Have a look at the documentation, it's pretty straight forward.
2) Create the Ajax autocomplete
This can be done using any library you want (jQuery, Prototype etc.) on the client side, and server side you handle this in your Controller action and replies with either JSON or a rendered template. There are plenty of tutorials for this out there. The Ajax result could include a link to create a new user, if none is found.
The Data Transformer is what you need to focus on, and I would get that working before working on the UI.

Related

MS ACCESS 2013 Displaying Data Rows for users to be able to click and open a new form

I'm just starting to get into Access due to my job and am tasked with creating a form that displays Data for the individual users on load. Basically what it needs to do is to get data from 3 tables, join them together, and then display the found rows that match that person's accounts they are responsible for managing.
I have this working via a single table Query using a listbox and a datasheet view, however, being a web developer by trade, I would like functionality that displays items similar to what a Unordered List(UL) would display and with functionality that allows the user to click on the company name(which acts as a hyperlink) to then update the information in a new form that I have built, by loading that data into the form, and allowing them to update the fields that I have designated as changeable.
Is this possible in Access via a form or would this be too difficult to implement? I'm decent with VBA, still learning what a lot of the things do, but as far as the logic and things like that to make something happen, I can do that no problem. These rows all have a unique ID so I would be able to either keep them in a collection to populate the form data or I can simply requery the data using the ID number for loading the form data.
A listbox performs like a combobox in datasheet view. Did you mean you have a combobox?
Actually very simple to accomplish, and various methods available. I assume you have a form bound to your Query with a combobox that lists companies. Controls have events. Use the Click event of the Company control. I use only VBA (not macros but macro could do this). Select [Event Procedure] in the event property. Click the ellipses (...) to open VBA Code Editor, type code into the procedure:
DoCmd.OpenForm "CompanyInfo", , , "ID=" & Me.tbxCompany
Keep in mind, controls used for the purpose of entering/selecting filter criteria should be UNBOUND, otherwise you would change data in record. However, using the Click event of a BOUND combobox (as long as you click on the box, not the dropdown) or textbox will not change existing data, not so for a listbox.

SYMFONY FORM - filter attribute form on top with submit button, that provides a table with other form used to edit each row details

I am looking for best practices on SYMFONY FORM handling to achieve the following standard page (surprisingly I haven't found anything similar existing yet on SO).
Here is a shema of what I want to achieve:
As you can see at the top there is a SYMFONY FORM to filter the results that should be displayed.
It displays a table and each tuple of the table should permit to open another SYMFONY FORM kind linked to the tuple.
I am in the process of learning SYMFONY FORM, so far, I can manage to create the top row FORM to set the filter that'll apply to the table display.
But I wonder if anyone has experience on the second part: Displaying the table that embed as well many forms of a similar kind -That seems a bit more complex. I read about TWIG.EXTENSION and FORM.COLLECTION, I'll investigate that. But if someone could save me to re-invent the wheel and lead me to some direct shortcut, I'd be really grateful.
No idea if it's the best practice, but one way to do it would be to create a new property for your entity being listed in this table, called $editionForm (without mapping it to the database) for example.
Then, either throught a custom loop or by listening to a doctrine (or any ORM you use) hydration event (or triggering such an event if you don't use any ORM), fill the property with the generated form, probably within a dedicated service.
Then, just use it in your template like this :
$entity->getEditionForm()->render()

Symfony: unique options in embedded form collection

I have an embedded form collection in Symfony. Which is working nice. I am working with a manytomany assocation mapping.
Except i want to create (with javascript?) the form so that only unique values are available. In my example i have an Organisation which can exist of many users. When i add user "L" in this case and i want to add a second user i want to prevent that user "L" is available in the other dropdown.
The way i embedded the collection of forms is exactly like the documentation of Symfony has learned me. (http://symfony.com/doc/current/cookbook/form/form_collections.html)
Down below is an example of how it works now (in this example I want to prevent that in the dropdown the user "L" is available as an option.
Thank you very much!
Unfortunately, there's no way you can make the HTML form behave this way. HTML forms just do not have any composite (or dependent) <select> widgets. So, the right way to go here would be:
validating the form server-side, so that duplicate values in two select boxes are not allowed;
adding some JavaScript code to the view that renders form. Perhaps this code should listen to <select>s' onChange events, and once an event is received, the option selected in the first box should either receive a disabled attribute or get deleted.

GWT Textfield with content assist kind of functionality

I am working on a project and I have a requirement to create one GWT Textfield. User should be able to put query in the text field. But this text field should have content assist (like Ecliplse) kind of functionality.
Example: "path" is one of the predefined object in the application with having certain attribute like "name","address". So now when user type "path.", it should show available attribute. This should work almost same way as in eclipse we get while put objectname it will give all available methods to call.
Example: User writes text "From path.name, path.attribute for object.attribute"
When user writes "from","for" it will not show any assistance but when user types "path." or "object." in above statement, it should show assist.
This is an interesting idea. You could try this with a suggest box widget.
GWT Suggest Box - http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwSuggestBox
GWTChosen Suggest Box - http://jdramaix.github.com/gwtchosen/
The above widget demos work with simple "contains" check on string. You would need to spend some serious logic on the regex matching if you want to pull of your idea.

Intercepting form submission and displaying results in cakephp without JS

In my Manager controller's add action I want to intercept the form submission, perform a search using the submitted data, and (if the query returns any results) display a list of results to the user.
My question is: what is the best way to display the results to the user? Should I just redirect to a different action (say search), or is there a nice way to display the data while remaining in the add action (session flash maybe)?
I know this can easily be done with the ajaxHelper and I am approaching this from that angle too, but I also need this functionality for my non-javascript users.
Any ideas appreciated!
badp,
you could just have a look at one of the generated (by cake bake controller ..., resp. cake bake view) controller methods named edit and look at the dataflow there.
It should be easy to adept it to your needs from there, as you can compare the dataflow and its outcome visually.