หน้า Customers ไปกดที่ New ขึ้น error แทนครับ โค้ด models -> customer.phpAn error has occurred.
0 Class "Joomla\CMS\MVC\Controller\FromController" not found
โค้ด: เลือกทั้งหมด
<?php
/**
* @package Joomla.Administrator
* @subpackage com_mexample
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
class MExampleModelCustomer extends \Joomla\CMS\MVC\Model\AdminModel
{
public function getForm($data = array(), $loadData = true)
{
return $this->loadForm('com_mexample.customer', 'customer', array('control' => 'jform', 'load_data' => $loadData));
}
public function getTable($name = 'Customer', $prefix = 'MExampleTable', $options = array())
{
return parent::getTable($name, $prefix, $options);
}
}
โค้ด: เลือกทั้งหมด
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="detail">
<field
name="name"
type="text"
label="COM_MEXAMPLE_NAME"
description="COM_MEXAMPLE_NAME_DECS"
required="true"
/>
<field
name="birthday"
type="calendar"
label="COM_MEXAMPLE_BIRTHDAY"
description="COM_MEXAMPLE_BIRTHDAY_DECS"
required="true"
/>
<field
name="gender"
type="radio"
label="COM_MEXAMPLE_GENDER"
description="COM_MEXAMPLE_GENDER_DECS"
default="1"
>
<option value="1">COM_MEXAMPLE_MALE</option>
<option value="2">COM_MEXAMPLE_FEMLE</option>
</field>
<field
name="age"
type="text"
label="COM_MEXAMPLE_AGE"
description="COM_MEXAMPLE_AGE_DECS"
required="true"
/>
<field
name="address"
type="textarea"
label="COM_MEXAMPLE_ADDRESS"
description="COM_MEXAMPLE_ADDRESS_DECS"
required="true"
/>
<field
name="phone"
type="text"
label="COM_MEXAMPLE_PHONE"
description="COM_MEXAMPLE_PHONE_DECS"
/>
<field
name="image"
type="file"
label="COM_MEXAMPLE_IMAGE"
description="COM_MEXAMPLE_IMAGE_DECS"
/>
<field
name="id"
type="hidden"
/>
</fieldset>
</form>
views -> customer -> view.html.php
โค้ด: เลือกทั้งหมด
<?php
/**
* @package Joomla.Administrator
* @subpackage com_mexample
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
class MExampleViewCustomer extends Joomla\CMS\MVC\View\HtmlView
{
public function display($tpl = null)
{
$this->item = $this->get('Item');
$this->form = $this->get('Form');
$this->state = $this->get('State');
$this->addToolbar();
parent::display($tpl);
}
public function addToolbar()
{
\Joomla\CMS\Toolbar\ToolbarHelper::title(JText::_('COM_MEXAMPLE_CUSTOMER_FORM'));
\Joomla\CMS\Toolbar\ToolbarHelper::apply('customer.apply');
\Joomla\CMS\Toolbar\ToolbarHelper::save('customer.save');
\Joomla\CMS\Toolbar\ToolbarHelper::save2new('customer.save2new');
\Joomla\CMS\Toolbar\ToolbarHelper::save2copy('customer.save2copy');
\Joomla\CMS\Toolbar\ToolbarHelper::cancel('customer.cancel');
\Joomla\CMS\Toolbar\ToolbarHelper::preferences('com_mexample');
}
}
โค้ด: เลือกทั้งหมด
<?php
/**
* @package Joomla.Administrator
* @subpackage com_mexample
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'tag.cancel' || document.formvalidator.isValid(document.getElementById('item-form'))) {
Joomla.submitform(task, document.getElementById('item-form'));
}
};
");
?>
<form action="<?php echo JRoute::_('index.php?option=com_mexample&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="item-form" id="item-form" class="form-horizontal">
<fieldset>
<?php foreach ($this->form->getFieldset('detail') as $field): ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
</fieldset>
</form>