How to add a button to a custom table that opens a form in a new tab and automatically fills out with data from that table I have a custom module where I create a table from some data. In one of the columns I need to have a button that when clicked will open a new tab and show the user a form and a submit button and some of the form fields are pre-filled with data from the table (data from the same row).

I know how to add a button but I don't know how to pass the data to the form.

Also, for the button I'm using the following code and maybe this is already wrong:

$new_button = '&lt;a href="/examples/form-example" target="_blank" class="btn btn-primary" role="button"&gt;New form&lt;/a&gt;';


Note: the data is not in the drupal database. The table is made on the fly using REST.

Any help will be greatly appreciated. Thanks!
Prepopulate module can pass value to form with query parameter.

Simple example:

&lt;a href="/node/add/content?edit[title]=This is the title" target="_blank" class="btn btn-primary" role="button"&gt;New form&lt;/a&gt;';


More examples can be found on its documentation.

If you find problems, please check this issue, some known bug has been introduced from 7.x-2.1 version. You may need to patch it.