Prestashop checkbox helperform not submitting to database - prestashop

I am using Prestashop 1.7 and am creating a module. I am using the helperform to generate it.
I am trying to have checkboxes so the customer can select multiple options.
The code I am using (under "protected function getConfigForm()") is:
array(
'type' => 'checkbox',
'label' => $this->l('Manufacturers'),
'name' => 'SERVICES_SELECTED',
'values' => array(
'query' => array(
array('key' => '1', 'name' => 'option 1'),
array('key' => '2', 'name' => 'option 2'),
array('key' => '3', 'name' => 'option 3'),
),
'id' => 'key',
'name' => 'name'
)
),
This shows up correctly in my admin>module config page.
However, when I select some values and click save, no data is submitted to the database.
Under
protected function getConfigFormValues()
I have
return array(
'SERVICES_SELECTED' => Configuration::get('SERVICES_SELECTED'),
);
I can get this to work for any other type of form e.g. text, select etc but checkbox just doesn't seem to save to the database.
Anyone got any ideas what I've missed?

Related

Prestashop 1.6 HelperForm add class fixed-width-x1 to form selector [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am creating a Prestashops 1.6 module. After added input in HelperForm select, then in html the script added class fixed-width-x1.
$fields_form[0]['form'] = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Add rule'),
),
'submit' => array(
'name' => 'add',
'title' => $this->l('Add'),
'class' => 'btn btn-default pull-right'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Category'),
'name' => 'category',
'required' => true
),
)
);
Screen Firebug
Why it works wrong?
I want add own class to select, but fixed-width-x1 override property width.
This class is automatically added by the HelperForm class in the proccess of rendering the select.
But, in my opinion, that you can do is add a class to the select and then change the style in this new class.
To add a new class to the select, only add this at the end of the options array:
'class' => 'name-of-custom-class'
Be sure that the comma after the last option exist.
In summary, should be like this:
$fields_form[0]['form'] = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Add rule'),
),
'submit' => array(
'name' => 'add',
'title' => $this->l('Add'),
'class' => 'btn btn-default pull-right'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Category'),
'name' => 'category',
'required' => true,
'class' => 'name-of-custom-class'
),
)
);
Hope it helps you.
[EDIT]
The HelperForm class uses a template to make this inputs. This template is:
/[admin-folder]/themes/default/template/helpers/form/form.tpl
In this file around the line 341, you can find this code:
{elseif $input.type == 'select'}
{if isset($input.options.query) && !$input.options.query && isset($input.empty_message)}
{$input.empty_message}
{$input.required = false}
{$input.desc = null}
{else}
<select name="{$input.name|escape:'html':'utf-8'}"
class="{if isset($input.class)}{$input.class|escape:'html':'utf-8'}{/if} fixed-width-xl"
In the last line you can see the place that is assigned this class with any control "fixed-width-xl".
The solution:
You can delete directly the class from the tpl, but this will affect
to all the inputs that are in the admin panel. And, in case of you want to update the prestashop version, is probably that you lost this change.
You can edit the admin css file deleting the "!important". This file is:
/[admin-folder]/themes/default/css/admin-theme.css

Where can i find a full list of InputeFilters Zend2 properties?

Where i can find a complit list of validator construction properties (factory). For exmple we got 1 inputeFilter 'email':
$this->add(array(
'name' => 'email',
'required' => true,
'validators' => array(
array(
'name' => 'EmailAddress',
'options' => array(
'domain' => true,
),
),
),
));
May be some documentation with all properties ('name', 'requiered. e.t.c.) and their structure.
they are all well documented just not in the array notation http://framework.zend.com/manual/current/en/modules/zend.validator.set.html
also you can view the invokables in the vendor code the variable is called $invokableClasses.
..\vendor\zendframework\zendframework\library\Zend\Validator\ValidatorPluginManager.php
For options you may still look at the documentation since they obviously vary from validator to validator.
Edit: In some cases building the validator out of the array notation is helpful. You'll just have to add them into the inputfilter notation like so:
...
$eanValidator = new Zend\Validator\Barcode(array(
'adapter' => 'EAN13',
'checksum' => false,
));
...
$this->add(array(
'name' => 'ean-test',
'required' => true,
'validators' => array(
array(
$eanValidator,
$someOtherValidator,
...
),
),
));

How to create a ZF2 FormCollection of the Doctrine ORM Module's ObjectSelect elements?

I have an odd situation where my add form works perfectly, but the edit form will not even load. Instead I get the following error:
Notice: Undefined property: DoctrineModule\Form\Element\ObjectSelect::$object in /vendor/zendframework/zendframework/library/Zend/Form/Element/Collection.php on line 517
Fatal error: Class name must be a valid object or a string in /vendor/zendframework/zendframework/library/Zend/Form/Element/Collection.php on line 517
I have objects of the class Application\Model\Record which have a many-to-many relationship to objects of the class Application\Model\Subject. I want the Subjects to appear as dropdowns in the Record forms, with the option to add multiple Subjects. So in the RecordFieldset.php I have:
$this->add(array(
'name' => 'subjects',
'type' => 'Zend\Form\Element\Collection',
'options' => array(
'label' => 'Subjects',
'count' => 1,
'should_create_template' => true,
'allow_add' => true,
'allow_remove' => true,
'template_placeholder' => '__subjectindex__',
'target_element' => array (
'name' => 'subject',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'object_manager' => $this->objectManager,
'target_class' => 'Application\Model\Subject',
'property' => 'name',
'empty_option' => 'Select a subject',
),
'attributes' => array(
'class' => 'form-control',
),
),
),
));
And like I said, this works perfectly in the Record add form. But it looks like on the edit form it cannot load the Subjects. Has anyone else tried something like this? Or do you have an idea what the error is saying?
Environment:
Zend Framework 2.3.3
Doctrine-orm-module 0.8.0
Doctrine 2.4.2
Looks like this is a bug on ZF2, target elements need to be a fieldset for it to work otherwise it will run into this issue. Use a fieldset to wrap the ObjectSelect.

nesting CGridView within Bootstrap Tabs

I'm using Yii-Booster TbTabs. I'd love to be able to nest CGridView in one of the tabs. I'm trying the following but getting the error "Object of class CGridView could not be converted to string".
$this->widget(
'bootstrap.widgets.TbTabs',
array(
'type' => 'tabs',
'tabs' => array(
array(
'label' => 'Tab 1',
'content' => '',
),
array(
'label' => 'Tab with grid view',
'content' =>$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'entry-subject-grid',
'dataProvider'=>$relatives->search(),
'filter'=>$relatives,
'columns'=>array(
'id',
'subject',
array('class'=>'CButtonColumn',),),)),),
array(
'label' => 'Tab 3',
'content' =>'description content',
),
),
)
);
This there any way that I can pass this object into a tab view (of example Im able to pass ckEditor quiate happily into a tab with the following
array(
'label' => 'Entry',
'content' => $form->ckEditorRow($model,'entry',array('options' => array('id'=>'new title'))),
),
thanks
The last parameter for Controller::widget() is captureOutput which when set to true returns the widget as a string instead of displaying it.

Customize getting data from SugarCRM Custom Module by Query parameter in rest api

Hi I'm trying to get data from SugarCRM by REST api. It's fine with default module, but with custom module, I got a issue.
I used this example
And getting data from Contacts module which has last name = "abc" is ok with these code:
$get_entry_list_parameters = array(
'session' => $session_id,
'module_name' => 'Contacts',
'query' => "contacts.last_name='abc'",
'order_by' => "",
'offset' => '0',
'select_fields' => array(
'id'
),
'link_name_to_fields_array' => array(
),
'max_results' => '1',
'deleted' => '0',
'Favorites' => false,
);
When I tried to get data from our custom module (eg: Event Session inside Event package), so it's ok as well without Query param like these code
$get_entry_list_parameters = array(
'session' => $session_id,
'module_name' => 'event_event_session',
'order_by' => "",
'offset' => '0',
'select_fields' => array(
'id',
'name'
),
'link_name_to_fields_array' => array(
),
'max_results' => '3',
'deleted' => '0',
'Favorites' => false,
);
But after that I put Query param, I got no record
$get_entry_list_parameters = array(
'session' => $session_id,
'module_name' => 'event_event_session',
'query' => "event_event_session.name='def'",
'order_by' => "",
'offset' => '0',
'select_fields' => array(
'id',
'name'
),
'link_name_to_fields_array' => array(
),
'max_results' => '3',
'deleted' => '0',
'Favorites' => false,
);
I think the way I used to get data from custom module is not correct.
Anyone can help me resolve this issue. Thank you!
Johnny
Are you sure the table name for the custom module is "event_event_session"?
When we create any new custom module using module builder then it is asking for key name. So our module will become as key_modulename. So make sure you are passing the key name along with module name. So that way you can access the data of custom new module.