DynamicFormWidget - Add Row with Values of other related models

Hi all,

I have started to use wbraganca\dynamicform\DynamicFormWidget in combination with mootensai\relation\RelationTrait and figured out a problem:

In my application users are able to manage their consulting projects. They can enter their time spended for the projects and also their travel expenses in case they travelled to the customer.

Now I started to implement the topic of bills. Here, it would be great if the users are able to add positions of project time and positions of travel expenses (not every travel and every time can be accounted to every customer).

The tables are:

project 1:n travel expenses

project 1:n project times

project 1:n bills

Therefor, I planned to display the positions (of project time and travel expenses) and wanted to add the positions for the bill with a button behind them. In the attachment I already did the design example for project time (in red some english translation). The buttons beside the project times should be able to add a new bill position with the given values.

7392

Unbenannt.png

Did anyone do sth. like this before?

I have no idea of how the solution could look like. I started by filling up one of the fields with a static string by Javascript jQuery(".dynamicform_wrapper").on("afterInsert", function(e, item) {}. But how do I get the data of the model in there?

Thanks for any kind of hints!

No one got an idea?

Last try :-[

I don’t understant exatly what you want to achieve, it seams to me a little bit confuse.

Ok,

in a simple way:

I want to add a data row to the DynamicFormWidget with data from another object.

In my example:

The form of the invoice consists of master data of the invoice itself (date, …) plus invoice positions that can be added with the DynamicFormWidget. Here I want to make it possible to adopt positions of e.g. travel expenses that are connected to the project (see attachment).

I hope that was easier to understand ::)

what do you mean by positions? Order them?

Invoices have got master data plus a number of invoice positions / items (sorry, I am not natice). The items are created using the DynamicForm.

All of the documentation that you need is at the following two pages

Multiple models

Dynamic form examples

Thanks, I got all the stuff working.

But my question is: How can I add rows and values to the DynamicForm with a button? Did someone do this with Javascript (where I am not really an expert in) before?

Did you want to add the rows and values for an update action? Can you be more clear on what you’re trying to do?