Ask your Symfony questions! Pay money and get answers fast! (more info)

How to do this complex embedded forms? Symfony

  • REFUNDED

I am going crazy with this embedded forms and I would like to see if someone can do it.

The problem is that it involves 4 different Tables/Forms with 1:1, 1:n and n:n relations.

I am also not sure how to do the thing to add creation form, for multiple items from within the form.

This is why I am offering a large price for this.

The specifics:

This is for a rules management module.

A rule is associated to a campaign.
A rule can have one or many commands.
Each command is linked to one or many Events (or Actions)
Each Event then is associated to a Campaign or to a Template.

I need to be able from a single form to edit those relations, with the possibility of adding only one rule at a time. However I should be able to add/modify/delete multiple Commands. Then I should be able to create the templates if needed.

I am attaching the schema and fixture on pastebin for easy reading.

Thank you.

Schema: http://pastebin.com/9J4SNU0n
Fixture: http://pastebin.com/QZxP0pTu


Answers (1)

2010-03-07

Gert Findel answers:

Each Event then is associated to a Campaign or to a Template. ??

1. If you have campaign->rules->commands->events.. why do you need event->campaign again?
2. Do you need new Commands for each new Rule or do you need to relate new rules with olds commands? Or Both?
3. Same as 2, but for Commands and Events.


Samuel comments:

This is to create rules for a Text message system.

1. The entire concept is that a rule will have one or both of two final effects:
a. Add/Remove/Update SOMETHING from a campaign. (Campaign is like an addressbook, so add/remove/uodate a contact to an address book for example or add information to a member of the address book)
b. Reply with a Template

So you can have 2 campaigns, and the rule will be: Rule for Campaign A: If inbound message from anyone, then Add contact to Campaign B <--


2. New commands for each rule. So Rule #1 may have Commands A,B and Rule #2 Commands A`, B` (different)

3. Yes. New for each.

Examples of the concept:

Rules 1 for Campaign 1
Command: "Add me!",
Events:
Add to Campaign 2
Remove from Campaign 1
Reply Template Thank you.
Command "Remove me from all!",
Events:
Remove from Campaign 1
Remove from Campaign 2
Reply Template Removed.

Rule 2 for Campaign 1
Command: "Yes!"
Events:
Reply Template: You said yes
Command: "No"
Events:
Reply Template: You said no



I hope this clarifies it.


Samuel comments:

Are you attempting to do this? :) Thank you.


Gert Findel comments:

yesterday before church i left it as you can see in [[LINK href="http://fb.acid.cl"]]this link[[/LINK]]
Is something like this what you want?
( I know there is something missing.. the possibility of inserting new Events in the commands, just as I did with the commands in the rule)


Samuel comments:

Yes. That is correct. Of course, implementing the Event and template part too.

(btw Adding new command for a new rule seems not to be working. only works for existing rules) . If it is a requirement to do in 2 steps to make it easier, I don't mind, something such as, Click Save on the rule, before displaying the command and event section.

Thank you.


Gert Findel comments:

or do you want to be able to select previously created commands for a rule? or previously created events for a command? If not, I don't understand why CommandEvent is N to N.


Samuel comments:

I am thinking.. you may be right... I may not need n:n ... Each rule is individual.. each command belongs to only one rule, and the events belong to that command.

The only thing in common, is that the Events can only be named Add, Remove, Modify and Reply, but I guess that can be controlled by doing a Choice with those commands only.

Ok, go ahead and modify the schema to reflect this... Thank you for noticing that.


Gert Findel comments:

I am back from work, I've uploaded a new version a my solution in the [[LINK href="http://fb.acid.cl"]]same link as before[[/LINK]]

I'm almost there =)


Gert Findel comments:

I was complicated with the ajax, so I started from scratch and did what you see in the [[LINK href="http://fb2.acid.cl/"]]folowing link[[/LINK]].. thats much easier, and means only 10 minutes
Is that what you need?

I believe it's all you need and is based in a plugin (ahDoctrineEasyEmbeddedRelationsPlugin), so its means almost no configuration and is very easy to understand and modify, specially the style.

PS: You still have to change your actual schema and fixture tio get it to work properly


Samuel comments:

Gert, thank you for the work so far.

But its still not working.. :(

Saving generated an error. I didnt test anything else.

Also there is no option to add more CommandS or more EventS

Remember one rule can have multiple commands, and each command can have multiple events.


Samuel comments:

Gert.. any luck with this?