Created
May 27, 2016 16:14
-
-
Save coolbung/dd363e8cf2b58b3df6f9f9335efc1984 to your computer and use it in GitHub Desktop.
Loading JForm field programatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// No direct access | |
defined('_JEXEC') or die; | |
//Get custom field | |
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); | |
$media_dummy = JFormHelper::loadFieldType('MediaUpload'); | |
$element_init = simplexml_load_string('<field name="dummy" type="mediaupload" mediaType="image" required="true" | |
accept="image/*" initCode="true" />'); | |
$media_dummy->setup($element_init, ''); | |
$media = JFormHelper::loadFieldType('MediaUpload'); | |
$element = simplexml_load_string('<field name="image" type="mediaupload" mediaType="image" required="true" | |
accept="image/*" />'); | |
$media->setup($element, ''); | |
echo $media_dummy; | |
echo $media; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This needs to be changed from
echo $media_dummy;
to
echo $media_dummy->getInput();
Also, getInput this needs to be
public
function in the field file.