making component,data not saving

by sanitar   Last Updated November 14, 2017 00:10 AM

Good day to all. I create my first component, for internal needs. up to a certain stage, the data was stored in a database, but then I decided to split the functionality a bit according to different views and that's all. no longer stores. when you click on the apply button - the application sends the form, and simply opens the address specified in the action, but does not save the data to the database.

events.xml:

<?xml version="1.0" encoding="utf-8"?>
    <form>
        <fieldset>
            <field
                name="id"
                type="hidden"
            />
            <field
                name="name"
                type="text"
                label="COM_SIMPLEEC_EVENT_NAME"
                description="COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_DESC"
                class="inputbox"
                default=""
            />
            <field
                name="color"
                type="text"
                label="COM_SIMPLEEC_EVENT_COLOR"
                description="COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_DESC"
                class="inputbox"
                default=""
                id="valueInput"
            />
        </fieldset>
    </form>

models/events:

defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.modeladmin');

class SimpleEventCalendarModelEvents extends JModelAdmin
 {


  public function getTable($type = 'EventsType', $prefix = 'SimpleEventCalendarTable', $config = array())
    {
        return JTable::getInstance($type, $prefix, $config);
    }
   public function getForm($data = array(), $loadData = true) {
        // Get the form.
        $form = $this->loadForm('com_simpleeventcalendar.events', 'events', array('control' => 'jform', 'load_data' => $loadData));
        if (empty($form))
            return false;

        return $form;
    }

    protected function loadFormData() {
        // Check the session for previously entered form data.
        $data = JFactory::getApplication()->getUserState('com_simpleeventcalendar.events.edit.data', array());

        if (empty($data))
            $data = $this->getItem();

        return $data;
    }


 }

controllers/events.php:

    defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controlleradmin');
class SimpleEventCalendarControllerEvents extends JControllerForm
 {
    public function getModel($name = 'Events', $prefix = 'SimpleEventCalendarModel')
    {
        return parent::getModel($name, $prefix, array('ignore_request' => true));
    }
 }

views/events/view.html.php:

defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.view');

class SimpleEventCalendarViewEvents extends JViewLegacy
{   

  protected $items;
  protected $form;
  protected $layout;

  public function display($tpl = null) {
  $this->layout     = $this->getLayout();
    try
        {
            $this->form = $this->get('Form');
            $this->item = $this->get('Item');

            $this->addToolBar();
            parent::display($tpl);
        }
        catch (Exception $e)
        {
            throw new Exception($e->getMessage());
        }
  }

  protected function addToolBar()
    {
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     JToolBarHelper::title(JText::_('COM_SIMPLEEVENTCALENDAR_GLOBAL_TITLE'));
     $doc=JFactory::getDocument();
     $doc->addStyleSheet(JURI::root(true).'/administrator/components/com_simpleeventcalendar/assets/css/simpleeventcalendar.css');
    }

  protected function getETypeList() {
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query->clear()
            ->select($db->qn('id'))->select($db->qn('name'))->select($db->qn('color'))
            ->from($db->qn('#__simpleec_etype'));
        $db->setQuery($query);
        return $db->loadObjectList();
    }
}

views/events/tmpl/edit.php:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
JHtml::_('behavior.tooltip');
$doc=JFactory::getDocument();
$doc->addScript(JURI::root().'/administrator/components/com_simpleeventcalendar/assets/js/jscolor.min.js');
?>
<form action="<?php echo JRoute::_('index.php?option=com_simpleeventcalendar&view=events&layout=edit&id=' . (int) $this->item->id); ?>" method="post" class="add_event_form" name="adminForm" id="adminForm" enctype="multipart/form-data">
<?php foreach ($this->form->getFieldset() as $field) : ?>
                <?php echo $field->label; echo $field->input;?><?php echo ($field->name=="jform[color]" ? "<button id='button_color_pick' class='btn jscolor {valueElement:jform_valueInput, styleElement:jform_valueInput}'><i class='icon-palette'></i></button>":"");?>
            <?php endforeach; ?>
  <?php echo JHTML::_('form.token')."\n"; ?>
  <input type="hidden" name="task" value="" />
</form>

whats' wrong???? i kill more than 12 hours to find the problem, but....



Related Questions


Adding a popup to com_users in joomla

Updated February 29, 2016 01:04 AM

Backend user view own articles

Updated May 13, 2017 20:10 PM

Admin menu items disappearing

Updated August 03, 2015 14:04 PM