jeffrey1984 Posted September 7, 2012 Share Posted September 7, 2012 This file is in the Classes folder <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class Test extends ObjectModel { /** @var string Name */ public $test; protected $fieldsRequired = array('test'); protected $fieldsSize = array('test' => 64); protected $fieldsValidate = array('test' => 'isGenericName'); protected $table = 'test'; protected $identifier = 'id_shop'; public function getFields() { parent::validateFields(); $fields['test'] = pSQL($this->test); return $fields; } } ?> This code is in admin/tabs <?php include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminTest extends AdminTab { public function __construct() { $this->table = 'test'; $this->className = 'Test'; $this->lang = false; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'id_test' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'test' => array( 'title' => $this->l('Name'), 'width' => 200) ); $this->identifier = 'id_shop'; parent::__construct(); } public function displayForm() { global $currentIndex; $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); $obj = $this->loadObject(true); echo ' <script type="text/javascript"> id_language = Number('.$defaultLanguage.'); </script>'; echo ' <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" class="width3"> '.( $obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '' ).' <fieldset><legend><img src="../img/admin/profiles.png" />'.$this->l('Profiles').'</legend> <label>'.$this->l('Name:').'</label> <div class="margin-form">'; foreach ($languages as $language) /* <input size="33" type="text" name="name_'.$language['id_lang'|'id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'|'id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup>*</sup>*/ echo ' <div id="name_'.$language['id_lang'|'id_lang'].'" style="display: '.($language['id_lang'|'id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;"> <input size="33" type="text" name="name_'.$language['id_lang'|'id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'|'id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup>*</sup> </div>'; $this->displayFlags($languages, $defaultLanguage, 'name', 'name' ); echo ' <div class="clear"></div> </div> <div class="margin-form"> <input type="submit" value="'.$this->l('Save').'" name="submitAdd'.$this->table.'" class="button" /> </div> <div class="small"><sup>*</sup> '.$this->l('Required field').'</div> </fieldset> </form> '; } } ?> this is in your developer guide but it doesnt work to me.. how to save the field test into database Sorry Im newbie in Prestashop Please Help Me Error Below: Link to comment Share on other sites More sharing options...
crcampos7 Posted October 31, 2012 Share Posted October 31, 2012 In the part name="name_'.$language['id_lang'|'id_lang'].'" change to name="test" Link to comment Share on other sites More sharing options...
kelvz Posted November 5, 2012 Share Posted November 5, 2012 is it resolved? Link to comment Share on other sites More sharing options...
Recommended Posts