Page 1 of 1

Load a file from a xml string ?

Posted: Mon Apr 23, 2012 8:21 pm
by duddy67
Hi,

In order to add some customized fields in the user form I builded
a profile plugin as described here
http://docs.joomla.org/Creating_a_profile_plugin

So in the onContentPrepareForm function, When I load my form from the xml file (profiles/profile.xml) it works right.

Code: Select all

JForm::addFormPath(dirname(__FILE__).'/profiles');
    $form->loadFile('profile', false);
but for some reasons I'd need to build some part of the form on the fly so
I tried to store the content of the xml file in a php variable:

Code: Select all

$myprofile = '<?xml version="1.0" encoding="utf-8"?>
                 <form>
	            <fields name="myprofile">
		           <fieldset name="myprofile"
			           label="PLG_USER_MY_PROFILE_SLIDER_LABEL" >

                      ...
         
                  </form>';
then load it:

Code: Select all

$form->loadFile($myprofile, false);
but the form is not loaded at all.

Can someone tells me where the problem comes from ?


Thanks

Re: Load a file from a xml string ?

Posted: Tue Apr 24, 2012 11:14 am
by duddy67
I got it.
Finally the solution was simple.
Just using load function instead loadFile.