I'm trying to render the media manager field type in a custom form. The form is not loaded from the xml.

this code is causing an error:

$obj = new JFormFieldMedia();
$obj -> __set('name','icon_image');   
$obj -> renderField();

Please can you help me?


What you've been missing is adding your element to your form object, as shown below:

$media = new JFormFieldMedia();
$media->name = 'icon_image';
$media->label = 'Image';

Without binding it to a form, it cannot retrieve its underlying value.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.