$data = array( 'name' => 'John Doe', 'email' => 'john@example.com', 'gender' => 'male', 'interests' => array('football', 'music') ); $form = JForm::getInstance('myform', 'path/to/myform.xml'); $form->bind($data); echo $form->getInput('name'); echo $form->getInput('email'); echo $form->getInput('gender'); echo $form->getInput('interests');
class User { public $name = 'John Doe'; public $email = 'john@example.com'; public $gender = 'male'; public $interests = array('football', 'music'); } $user = new User(); $form = JForm::getInstance('myform', 'path/to/myform.xml'); $form->bind($user); echo $form->getInput('name'); echo $form->getInput('email'); echo $form->getInput('gender'); echo $form->getInput('interests');This code creates an instance of the User class, which has public properties that correspond to the form field names. It then populates the form fields with data from the object using the bind() method, and renders the form fields using the getInput() method. Both examples use the JForm package library in Joomla.