I am working on a bit of functionality that allows a 'form' to be embedded in a custom views field on a view I am working on.
The view is a table list of 'request' entities. The very last column in the table for each row is a 'quick edit' form, that has a custom form with a few fields on it (depending on the entity displayed in the current row). I am trying to figure out how to build a custom views plugin/field that will let me render a working form. I know how to do the logic to show the needed fields conditionally, and know how to build a normal form, but I am not sure how to build one into a views field.
I used `drush generate plugin-views-field' and I can render form elements in the render() method, but they don't actually do anything as a form isn't actually generated.
Would it be easier/possible to create a form inside module/src/Form (that accepts additional arguments), and render that form using formBuilder->getForm() or is there a way I can build and render the form inside of a views plugin?
The form needs to work via ajax, so that you can make the quick-edit without reloading the page.
Any help would be greatly appreciated.
According to the comments below, it looks like I can do something like:
$form = \Drupal::formBuilder()->getForm('Drupal\resume\Form\WorkForm');
$form->sub_id = id;
return $form;
To render the form, and then inside the formbuilder use the sub_id variable to attach it to the ajax callback and wrapper element.