I have created a simple form field:
class myField extends formField {
function Field()
{
Requirements::javascript('mymodule/test.js');
//Requirements::javascript($this->BaseHref() . 'mymodule/test.js'); // Also tried this
return 'hello, world';
}
}
All test.js does is issue the alert "Hi there!".
Now, I can add this field to a DataObject's form, and it correctly displays the message "hello, world" in the form in the expected place. However, the JavaScript does not appear to be anywhere. I realise the forms are displayed using AJAX in the AdminManager scaffolding thingy, but is it not supposed to also pull in additional JavaScript when the form is loaded?
Or maybe that is not an automatic thing and I am missing out some vital step? The documentation does not seem to cover how the JS and AJAX interact (there are some essays on ways it *could* be done, but nothing that clearing states "this is how it works...").
Any clues what I'm missing?
-- Jason