jawaid Posted May 27, 2015 Share Posted May 27, 2015 I am able to display my custom field in Feature Value Add/Edit form by overriding AdminFeaturesController and overriding initFormFeatureValue() function. I want to do the same for Feature Add/Edit form but cannot find function to override. I tried renderForm() function but didn't work. Which file/class/controller/function should I look into to override Feature Add/Edit form to display my custom field? Link to comment Share on other sites More sharing options...
tuk66 Posted May 28, 2015 Share Posted May 28, 2015 Hard to say. A developer have to see all your code and debug it. Link to comment Share on other sites More sharing options...
jawaid Posted May 30, 2015 Author Share Posted May 30, 2015 Hard to say. A developer have to see all your code and debug it. I fixed the issue. Solution is available here http://stackoverflow.com/questions/30472428/prestashop-1-6-display-custom-field-in-feature-add-edit-form But now there is new problem that my custom field doesn't get saved in database while other default fields are. My code is available at GitHub https://github.com/mjawaids/advancedfeaturesvalues If anyone can see what the issue is and if I'm missing anything. Link to comment Share on other sites More sharing options...
Eject-computer Posted June 12, 2015 Share Posted June 12, 2015 I had the same trouble, i want to show categories and asign features to product categories. I did it, i make a dropdown list, but it only save to database form info when i'm adding a feature, if i try to edit it dosn't work. To make the form saves, you have to edit /classes/feature.php and add to feature class new fields you want to save. you have edit definition too. I don't know how to update the file, but if you are interested to see it, put a reply. Link to comment Share on other sites More sharing options...
jawaid Posted June 12, 2015 Author Share Posted June 12, 2015 @eject-computer, so what you're saying you modified feature.php file for this? I see only one definition that I assume works for both add and edit. So, how actually you solved it? Link to comment Share on other sites More sharing options...
Eject-computer Posted June 15, 2015 Share Posted June 15, 2015 Yes, I edit feature.php and add public $id_category in class attributes, and 'id_category' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedId'), in class definition. Link to comment Share on other sites More sharing options...
sdumont_lsm Posted January 7, 2016 Share Posted January 7, 2016 Hello, I've got the same problem with my override of Feature class. I modified feature.php and AdminFeaturesController.php to add my custom field and I created the field in database. When I add a new feature, my custom field is correctly saved in database and appears in my form. But when I'm editing an existing feature, my custom field is not saved. Weirdly, i made the same process with Category class and it works fine ! Here is my code (my custom field is named "reference_lcv") : Feature override <?php class Feature extends FeatureCore { public $reference_lcv; public function __construct($id = null, $id_lang = null, $id_shop = null) { self::$definition['fields']['reference_lcv'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255, 'required' => true); parent::__construct($id, $id_lang, $id_shop); } } ?> AdminFeaturesController override <?php class AdminFeaturesController extends AdminFeaturesControllerCore { public function __construct() { parent::__construct(); } public function renderForm() { $this->toolbar_title = $this->l('Add a new feature'); $this->fields_form = array( 'legend' => array( 'title' => $this->l('Feature'), 'icon' => 'icon-info-sign' ), 'input' => array( // AJOUT LSM array( 'type' => 'text', 'label' => $this->l('Référence LCV'), 'name' => 'reference_lcv', 'lang' => false, 'required' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'lang' => true, 'size' => 33, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'required' => true ) ) ); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso', ); } $this->fields_form['submit'] = array( 'title' => $this->l('Save'), ); return AdminController::renderForm(); } } ?> Thanks for any help ! 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