I tried to display a form in the frontend. But i always get the error:
Code: Select all
Fatal error: Call to undefined method mvcModelmvc::loadForm() in /home/usr/bksolution/public_html/components/com_mvc/models/mvc.php on line 19
- com_mvc
com_mvc/mvc.xml
com_mvc/admin
com_mvc/site
com_mvc/site/controller.php
com_mvc/site/mvc.php
com_mvc/site/models
com_mvc/site/models/mvc.php
com_mvc/site/models/forms
com_mvc/site/models/forms/form.xml
com_mvc/site/views
com_mvc/site/views/mvc
com_mvc/site/views/mvc/view.html.php
com_mvc/site/views/mvc/tmpl
com_mvc/site/views/mvc/tmpl/default.php
com_mvc/site/controller.php
Code: Select all
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* Workshop Component Controller
*/
class MvcController extends JController
{
}
?>
Code: Select all
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import joomla controller library
jimport('joomla.application.component.controller');
// Get an instance of the controller prefixed by Workshop
$controller = JController::getInstance('Mvc');
// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));
// Redirect if set by the controller
$controller->redirect();
?>
Code: Select all
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla modelitem library
jimport('joomla.application.component.modelitem');
class mvcModelmvc extends JModelItem
{
/**
* Method to get the form.
*
* @access public
* @return mixed JForm object on success, false on failure.
*/
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm(
'com_mvc.mvc',
'form',
array('control' => 'jform', 'load_data' => $loadData)
);
return $form;
}
}
?>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="primary_fieldset">
<field
id="id"
name="id"
type="hidden"
/>
<field
id="primary"
name="primary"
type="list"
label="Primary Selection"
default="red">
<option value="red">Red</option>
<option value="blue">Blue</option>
</field>
</fieldset>
<fieldset name="secondary_fieldset">
<field
id="id"
name="id"
type="hidden"
/>
<field
id="secondary"
name="secondary"
type="list"
label="Secondary Selection"
default="green">
<option value="green">Green</option>
<option value="yellow">Yellow</option>
</field>
</fieldset>
</form>
Code: Select all
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
class mvcViewmvc extends JView
{
/**
* View form
*
* @var form
*/
protected $form = null;
/**
* display method of MVC view
* @return void
*/
public function display($tpl = null)
{
// get the Form
$form = & $this->get('Form');
// get the Data
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("<br />", $errors));
return;
}
// Assign the form
$this->form = $form;
// Display the template
parent::display();
}
}
?>
Code: Select all
<div class="first-fieldset">
<form name="formname">
<fieldset class="adminform">
<legend>Primary Fields</legend>
<?php foreach ($this->form->getFieldset('primary_fieldset') as $field): ?>
<?php echo $field->label; ?>
<?php echo $field->input; ?>
<?php endforeach; ?>
</fieldset>
</form>
</div>
Can anyone tell me, why I get this error? I did exactly how it was in the documentation: https://docs.joomla.org/API16:JForm/getFieldset