Customize getting data from SugarCRM Custom Module by Query parameter in rest api - 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.

Related

Prestashop checkbox helperform not submitting to database

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?

CJuiDatePicker in yii is not working

In my web application, I want to implement a date field. For this i am using CJuiDatePicker. But for me it not showing calendar.
My code is,
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'Employee[employee_joiningdate]',
'id' => 'Employee_employee_joiningdate',
'value' => Yii::app()->dateFormatter->format("d-M-y", strtotime($model->employee_joiningdate)),
'options' => array(`
'showAnim' => 'slide', //'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
'showOtherMonths' => true, // Show Other month in jquery
'selectOtherMonths' => true, // Select Other month in jquery
),
'htmlOptions' => array(
'class' => 'form-control'
),
));`
What i am doing wrong?
Please help me....
Thanks in advance.

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.

Error with dijit.form.NumberTextBox

Despite many trials and errors, I cannot get the NumberTextBox widget to work. I keep receiving this error message:
Catchable fatal error: Argument 4 passed to Zend_Dojo_View_Helper_NumberTextBox::numberTextBox() must be an array, null given
The odd thing is: I event tried this example straight from the ZF examples page and it failed with the same error
->addElement(
'NumberTextBox',
'numberbox',
array(
'label' => 'NumberTextBox',
'required' => true,
'invalidMessage' => 'Invalid elevation.',
'constraints' => array(
'min' => -20000,
'max' => 20000,
'places' => 0,
)
)
)
So, I'm at a loss now. If someone has the time to look at the code found here, your help would be greatly appreciated. I know it's something that I'm overlooking. It always is.
If you are setting decorators, make sure you change ViewHelper to DijitElement. I ran into this problem and that was the cause.
Shot in the dark: try getting rid of the ',' at the end of 'places' => 0,'
I use a base Form,
BaseForm extends Zend_Dojo_Form{
public $elementDecorators = array(
'DijitElement',
array(
array('data' => 'HtmlTag'),
array('tag' => 'div', 'class' => 'element')
),
array('Label',
array('tag' => 'div', 'class' => 'element-label')
),
array(array('row' => 'HtmlTag'),
array('tag' => 'div', 'class' => 'element-row' )
)
);
... init(){}
.... construct(){}
}
MyForm extends BaseForm{
constructor(){
$this->starts = new Zend_Dojo_Form_Element_DateTextBox( "starts" );
$this->starts->setLabel('Starting from')
->setDecorators($this->elementDecorators);
}
}
I made the source code as simple as possible, to depict the idea of what I mean.