Jump to content

banditbirds

Recommended Posts

Hi all,

 

I created a class for my module which uses helper form to edit a record in my table.

 

AdminBlockQuoteController

 

My SQL query successfully loads the data to the list. But when I select to edit a record, it loads the form, but with no data.

 

When I debug using smarty console, my fields_list values are empty.

 

 

I've created this looking at the 1.6 document http://doc.prestashop......

 

Could anyone help?

 

Thanks!!

 

Simon

<?php

class AdminBlockQuoteController extends ModuleAdminController {

public function __construct() {

   $this->context = Context::getContext();
   $this->bootstrap = true;
   $this->table = 'custom_order';
   $this->identifier = 'id_custom_order';
   $this->className = 'BlockQuote';
   $this->lang = false;
   
   $this->_select = 'CONCAT(LEFT(cu.`firstname`, 1), \'. \', cu.`lastname`) AS `customer` ';


   $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` cu ON (cu.`id_customer` = `user_id`)';


   $this->fields_list = array(


   'id_custom_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
   'request_details' => array('title' => $this->l('Request Details'), 'width' => 230),
   'date_needed' => array('title' => $this->l('Date Needed By'), 'align' => 'center', 'width' => 30),
   'request_price' => array('title' => $this->l('Request Price'), 'align' => 'center', 'width' => 20),
   'customer' => array('title' => $this->l('Customer'), 'align' => 'center', 'width' => 40),
   'quote_price' => array('title' =>$this->l('Quote Price'), 'align'=>'center', 'width' => 20),
   'date_agreed' => array('title' =>$this->l('Date Agreed'), 'align'=>'center', 'width' => 30),
  );


  $this->bulk_actions = array(
'delete' => array(
        'text' => $this->l('Delete selected'),
  'confirm' => $this->l('Delete selected items?'),
  'icon' => 'icon-trash'
)
  );
  
  parent::__construct();


}


    // This method generates the list of results
    public function renderList()
    {
        // Adds an Edit button for each result
        $this->addRowAction('edit');
  
        // Adds a Delete button for each result
        $this->addRowAction('delete');
  
        return parent::renderList();
    }


 public function renderForm() {
        
        
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Edit Quote'),
'icon' => 'icon-envelope-alt'
),


'input' => array(
array(
'type' => 'textarea',
'label' => $this->l('Request Details'),
'name' => 'request_details',
'required' => true,
'lang' => false,
'col' => 6,
'hint' => $this->l('Details of the custom request'),
),
array(
'type' => 'date',
'label' => $this->l('Date Requested'),
'name' => 'date_needed',
'required' => false,
'col' => 4,
'hint' => $this->l('Date requested by customer'),
),


array(
'type' => 'text',
'label' => $this->l('Price Requested'),
'name' => 'request_price',
'required' => false,
'lang' => false,
'col' => 4,
'hint' => $this->l('Price requested by customer'),
),
array(
'type' => 'text',
'label' => $this->l('Quote Price'),
'name' => 'quote_price',
'required' => false,
'lang' => false,
'col' => 4,
'hint' => $this->l('Price quoted by store'),
),
array(
'type' => 'date',
'label' => $this->l('Date Agreed'),
'name' => 'date_agreed',
'required' => false,
'lang' => false,
'col' => 4,
'hint' => $this->l('Date quoted by store'),
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
 
return parent::renderForm();
}


}

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

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
×
×
  • Create New...