Form_builder js in Fuel admin
I have a situation where I'm creating dynamic inputs in a simple module in Fuel's admin, and using the on_after_save() method to pick up the POST parameters and process them.
If the values pre-exist in relation to the form record, then form_fields() is rendering them from the model. If new inputs are required, a js Controller is creating them, using a button's click event handler. This all works OK.
However, I don't like repeating 2 lots of identical form input HTML in the Controller js and in PHP (the model), so it seems a good idea to get this HTML generation for new elements all done in the model, and by form_fields(). It will still require javascript, but the script could be defined in the model.
I can of course add javascript via a Form builder input, but is there a way, from form_fields(), of adding or appending to the form's js property? The functionality seems relevant to the form as a whole, rather than being loaded arbitrarily by a given input field.
Comments
$fields['__FORM_BUILDER__'] = array('js' => '<script>alert("YO");</script>');
Thank you.