开发者

PHP : inheritance logical (extends)

This may sound as a non related coding question but it's directly related :

The facts: I've developped a website (with symfony) which allows players to search for a team (like a job board). It makes one module only.

The problems I want the website to be even more accurate and make a custom form for each players depending on the game (for example, for those who play "league of legends" they'll have 3 more informations to fill up....)

The solutions?

  • One module per game (example: http://pastie.org/private/cl48jsrjreukyjmj7jrk8a).

I'm currently developping 1 module per game in order to take in consideration the specific criteria for specific games.

Advantages : The player enters the informations in relation with his game and does not see/interact the other criteria

Disavantages: 90% of the code are the same between each modules. It takes more time.


  • Inheritance

I never played开发者_JAVA技巧 with that before so i don't know if it's possible in my case to stick with 1 module for the entire game collection AND taking in consideration the specific criterias for games. In that case it would mean to have 1 template per game and displaying the right template with the right accessors like ($this->getCV()->getPseudo(); / $this->getCV()->getGame()->getSpecificCriteria1();)


If I have read your question correctly, you want to show additional fields for each specific game.

Solution 1

Create a 2 form process. After your first form, you could redirect the user to a second form which depends on their answers. To do this, in your first form, use a redirect to send the user to a game-specific second form.

Solution 2

Pass the name of the game to the template and show a customised partial for the extra form fields. For this you will need a Url with a game parameter like this:

www.example.com/form/show/:game_identifier

Then in your action, read the parameter and pass it to your template. In the template, show a partial dependant on the game that was passed through. So only show the extra fields if a specific game was chosen before hand.

There are further ways to accomplish this but these 2 sprung to mind first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜