sviluppoMeloni Posted May 19, 2018 Share Posted May 19, 2018 (edited) Hi, I try to add 2 fields in the module ps_slider configuration page. First of all I added 2 fields datetime in the database - date_start -date_end In the file Ps_HomeSlide.php: public $date_start; public $date_end; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'homeslider_slides', 'primary' => 'id_homeslider_slides', 'multilang' => true, 'fields' => array( 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), 'position' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true), // Lang fields 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 4000), 'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 255), 'legend' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 255), 'url' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isUrl', 'required' => true, 'size' => 255), 'image' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 255), //modifica Ale 'date_start' => array('type' => self::TYPE_DATE, 'lang' => true, 'validate' => 'isDate'), 'date_end' => array('type' => self::TYPE_DATE, 'lang' => true, 'validate' => 'isDate'), ) ); in the file ps_imageslider.php in the renderAddForm method I add after textArea description array( 'type' => 'date', 'label' => 'Inizio', 'name' => 'date_start', 'size' => 10, 'required' => true, 'lang' => true, ), array( 'type' => 'date', 'label' => 'Fine', 'name' => 'date_end', 'size' => 10, 'required' => true, 'lang' => true, ), and in the method getAddFieldValues I add this code: foreach ($languages as $lang) { $fields['image'][$lang['id_lang']] = Tools::getValue('image_'.(int)$lang['id_lang']); $fields['title'][$lang['id_lang']] = Tools::getValue('title_'.(int)$lang['id_lang'], $slide->title[$lang['id_lang']]); $fields['url'][$lang['id_lang']] = Tools::getValue('url_'.(int)$lang['id_lang'], $slide->url[$lang['id_lang']]); $fields['legend'][$lang['id_lang']] = Tools::getValue('legend_'.(int)$lang['id_lang'], $slide->legend[$lang['id_lang']]); $fields['description'][$lang['id_lang']] = Tools::getValue('description_'.(int)$lang['id_lang'], $slide->description[$lang['id_lang']]); //new fields $fields['date_start'][$lang['id_lang']] = Tools::getValue('date_start_'.(int)$lang['id_lang'], $slide->date_start[$lang['id_lang']]); $fields['date_end'][$lang['id_lang']] = Tools::getValue('date_end_'.(int)$lang['id_lang'], $slide->date_end[$lang['id_lang']]); } In the configuration page I see the 2 new fields but not load the datetime value saved in the database. I don't know why. Please help me Thank you in advance Alessandro Edited May 19, 2018 by sviluppoMeloni (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now