Matte01990 Posted November 17, 2016 Share Posted November 17, 2016 Hello everybody. Is it possible to change title and description field max-length in custom modules? In my database table I have a varchar(255) column for 'title' and a 'text' column for 'description', but my db settings seem to be useless: when I create a new row in my table and click submit, if my input has more than 10 characters or something, no new line is created. It works fine with inputs with length < 10. Here it is my relevant code: <?php class AdminMyBlockContentController extends ModuleAdminController { public $bootstrap = true ; public function __construct() { $this->table = 'my_block_content'; $this->className = 'MyBlockContent'; $this->lang = true; $this->addRowAction('view'); $this->addRowAction('edit'); $this->addRowAction('delete'); //fields display $this-> fields_list = array( 'id_my_block_content' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'nome' => array('title' => $this->l('Name'), 'width' => 120), 'desc' => array('title' => $this->l('Description'), 'width' => 120), 'link' => array('title' => $this->l('Link'), 'width' => 120), 'file_url' => array('title' => $this->l('file_url')), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'class' => 'fixed-width-xs') ); parent::__construct(); } //add form public function renderForm() { if (!($obj = $this->loadObject(true))) return; $this->fields_form = array( 'legend' => array( 'title' => $this->l('Add/Edit Box') ), 'input' => array( array( 'type' => 'text', 'label' => 'Nome', 'name' => 'nome' ), array( 'type' => 'textarea', 'label' => 'Description', 'name' => 'desc', 'autoload_rte' => 'rte' //Enable TinyMCE editor for short description ), array( 'type' => 'file', 'label' => $this->l('file_url'), 'name' => 'file_url', 'display_image' => true ), array( 'type' => 'text', 'label' => 'Link', 'name' => 'link' ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ) ) ), 'submit' => array( 'title' => $this->l('Save'), 'name' => 'submit_form' ) ); return parent::renderForm(); } public function postProcess() { //checks if submit if (Tools::isSubmit('submit_form')) { //insert data into my_block_content $insertData = array( 'nome' => Tools::getValue('nome'), 'desc' => Tools::getValue('desc'), 'active' => Tools::getValue('active'), 'link' => Tools::getValue('link'), 'file_url' => Tools::getValue('file_url') ); Db::getInstance()->insert("my_block_content", $insertData); } //checks if delete elseif (Tools::isSubmit('delete').$this->table) { Db::getInstance()->delete('my_block_content', 'id_my_block_content = '.$_GET[id_my_block_content]); } } } Link to comment Share on other sites More sharing options...
Matte01990 Posted November 18, 2016 Author Share Posted November 18, 2016 (edited) Solved. The issue was due to some special characters that were not allowed. Edited November 18, 2016 by Matte01990 (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