Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony 1.4 form fields depending on configuration
    primarykey
    data
    text
    <p>I use symfony 1.4 in my php project. I've got a form which might be extended depending on user configuration. If user chooses additional labels or budget for tasks, this information ought to be embedded to form class and displayed as widget in form partial (additional inputs). </p> <p>For example: </p> <ol> <li><p>Admin wants to have only basic tasks without buget or labels. Only TasksForm widgets are displayed when editing or creating new task.</p></li> <li><p>Admin wants to have basic tasks with labels. TasksForm is displayed with additional field that enables user to choose labels.</p></li> <li><p>Admin wants to have all options (labels + budget)</p></li> </ol> <p>Relations in db are:</p> <pre><code>Tasks: columns: name: string(127) created_at: timestamp updated_at: timestamp Budget: columns: task_id: integer budget_prognosis: integer budget_used: integer relations: Tasks: local: task_id foreign: id type: one TaskHasLabel: columns: task_id: type: integer primary: true label_id: type: integer primary: true relations: Tasks: local: task_id foreign: id type: one onDelete: CASCADE Labels: local: label_id foreign: id type: one onDelete: CASCADE Labels: columns: name: string(127) relations: Tasks: class: Task local: label_id foreign: task_id refClass: TaskHasLabel </code></pre> <p>Aim is to easily change configuration of forms and add new configuration options in the future. I know I could do this by creating separate form for every combination, but I don't want to repeat myself. Another idea is to combine all fields in one form and hide them, but it doesn't seem to me like a good idea. I thought of configuration via parameters in form constructor, but I'm not sure of that either. What's the best practice in this situation?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload