Symfony Embedded Relation Many2Many - linking unique fields or creating new fields - symfony1

I'm using an embedded relation to allow the user to edit/add books to a library and in the same form to add/remove n authors who wrote the book within the auto generated admin.
Here is my problem: An authors name is unique, so when I enter an author that already exists the sfValidatorDoctrineUnique produces the error.
An object with the same "name" already exist.
What I want to do is catch this error and tell the form not to try to add the exisiting author anew.
Do I use the event system for that, or modify the validators or how can I do that?
thank you very much
hoodie
PS:
after some searching I found something that might be a solution but I haven't made it work yet
http://symfonyguide.wordpress.com/2009/09/28/symfony-forms-saving-process/

I my opinion you should not to add new author if it already exists.
sfDoctrineActAsTaggablePlugin do the same way. It searches for an existing tags and merge them with current (added by user from form) tags.
But here is one issue: Two authors - Aleksander Pushkin and Alexander Pushkin, is it same authors for us, but different for machine.

Related

Umbraco Extending Tags

I am new to Umbraco CMS, so this question may sound silly. The requirement is to show the tags (based on a specific tag group) to editors in a dropbox, and they could able to choose these tags and save it to the article. What is the best way of achieving this?
The tag property allows free text entry. If you only want editors to select from a predefined list of options you will probably need to do this a different way. You may want to try the dropdown property with the multiple choice option turned on instead. Then you can setup the prevalues (options) ahead of time and your editors can only select from that list.
You could also create a container in the tree for your categories and then allow your admins to select the appropriate items from that list using a multinode tree picker. Here's kind of an example of how you might structure this for a blog:
Blog
Authors
Author
Categories
Category
Posts
Post
Then when an admin adds a new post you would allow them to select the appropriate authors/categories for the post using a multinode tree picker.

Xtext - Temporarily tolerate unresolvable references and make the reference name user readable

Let's say I have a language that models a part of stackoverflow. Users are held in one resource, questions in another.
Users:
user fred : fred#foobar.com
user notfred : notfred#foobar.com
Questions:
question 123 by fred message "smart question"
question 124 by notfred message "not so smart question"
Now, the user "fred" wants to remove his account, but this wouldn't work because after loading both resources into my ResourceSet I would have a non-empty Resource#getErrors().
I can work around this by filtering XtextLinkingDiagnostic from the errors, but still other users reading the "smart question" cannot tell anymore that it was asked by someone called "fred". The info is still there, I can access it for example when I set a LinkingDiagnosticMessageProvider with LazyLinkingResource#setDiagnosticMessageProvider(...); however, the best thing I can now do is, show other users validation errors that "fred" was deleted, but they wouldn't know "fred" wrote the message they are just reading. Knowing this would help them a lot because everybody knows that "fred" writes great questions, right?
Long story short, I have an application into which users can load a declaration and a definition file. In very few cases something goes wrong and both files don't match perfectly, which means the definition has entries that are not declared in the declaration. However, I know that ~95% of the entries will still match!
Users cannot fix this quickly, but it is likely that they are happy just editing the 95% definitions, but they still need to be able to read the names of the 5% declarations without editing them!
I am not currently using any UI-parts of Xtext to edit the definitions, but rather a custom UI in form of a table. The current state with the missing declarations is that everything except a value column will be empty. The reference ID would be in another column, and knowing this ID would help the user a lot! Is there a clean way to achieve this?
Have a look at the 'Node Model' e.g. org.eclipse.xtext.nodemodel.util.NodeModelUtils.findNodesForFeature(EObject, EStructuralFeature) allows you to access the text that is written in the file

Saving data and displaying it in a form Rails 4

I have created a call report form with my contact's first name & contact's last name in my scaffold. Although I can clearly see the fields in the form and I can go ahead and edit them, the fields of contact_first_name & contact_last_name are always empty after being saved and returning to my view. I don't know what to do or how to approach this issue.
Any suggestions would be greatly appreciated.
There could be many problems:
contact_first_name or contact_last_name could be misspelled.
in controller they may not be permitted
you might be overriding these fields somewhere
etc etc
Possible solutions or the directions to the solution are:
check database for their existence
check spells
check them in permit list
check the logs
But Code would be helping for both you and answering persons. So please post code with your question.

Symfony Edit Specific Related Records

I have an app that I have a model that supports multiple addresses, but upfront I only want to allow the user to add/edit one address.
User
----
UserId
Address
----
UserId
Line1
...
I have the following to render the form for adding a new address, but how about existing records? What do I need to add to my configure method in the User form?
$this->embedForm("address", new AddressForm());
Take a look at More with Symfony: Advanced Forms. This chapter outlines a good way to embed multiple forms when dealing with 1-to-many relationships and should more than cover explaining what you need to do.

How to design a system like google base with dynamic attributes? in Ruby on Rails

I am wanting to create an application that can allow users to add products for sale.
I want to make it so that a user can add whatever type of product he/she likes and let them also create stored and searchable attributes for their products - alot like google base does.
Does anyone know of the best way to do this ie model it.
I don't really want a table for each category as this would be possibly 1000s of tables.
What is the best way to do this? has anyone got good / bad experiences of this?
Is there any plugins that does this?
Any help would be great
thanks
rick
It sounds like what you want is a tag system.
If you want something more flexible you might want to look at using a document store instead of a database, for example CouchDB.
If you don't want to keep this in a relational database I'd suggest creating a Model called "Descriptor" that would contain the ID of the item being added, the name of the attribute "Color" and the value "Red".
To help keeps things consistent you could also structure pre-set groups of descriptors (for cars: make, model, color) as well as provide auto-completes for the value entry text fields.

Resources