Jump to content

Module send data using ObjectModel


set4812
 Share

Recommended Posts

I creating module using example module from this page

https://github.com/PrestaEdit/Canvas-Module-Prestashop-15

I configured my module take data from db and print . Now i trying add something to db. But i have problem i dont now how ;(.

I taking error from debug

[b]Property ExampleData->idp is empty[/b]

This is my code now what i doing bad to insert to db?

<?php
class ExampleData extends ObjectModel
{
    /** @var string Name */
   public $idp;
   public $price;

   /**
    * @see ObjectModel::$definition
    */
   public static $definition = array(
       'table' => 'auction',
       'primary' => 'id_auction',
       'multilang' => true,
       'fields' => array(
           // Lang fields
           'idp' =>         array('type' => self::TYPE_INT,'required' => true),
           'price' =>         array('type' => self::TYPE_INT,'required' => true)
       ),
   );
}
?>

Render function

   public function renderForm()
   {
       $this->fields_form = array(
           'tinymce' => true,
           'legend' => array(
               'title' => $this->l('Example'),
               'image' => '../img/admin/cog.gif'
           ),
           'input' => array(
               array(
                   'type' => 'text',
                   'label' => $this->l('idp'),
                   'name' => 'idp',
                   'size' => 50
               ),
               array(
                   'type' => 'text',
                   'label' => $this->l('price'),
                   'name' => 'price',
                   'size' => 40
               ),
               array(
                   'type' => 'text',
                   'label' => $this->l('time'),
                   'name' => 'datetime',
                   'size' => 40
               ),
           ),
           'submit' => array(
               'title' => $this->l('Zapisz'),
               'class' => 'button'
           )
       );

       if (!($obj = $this->loadObject(true)))
           return;


       /*gestion de l'affichage de la vignette
       @TODO : problème, suppression d'image */
       $this->fields_value = array('idp' => 2,'price' => 1000);

       return parent::renderForm();
   }

 

I near to end my module i need only add update and insert

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More