sugarcrm display field in editview based on value in user details - php

I am trying to display a field in editview alone based on a fieldvale in userdetails.
Ex: For an user can_add_no will be in user details, if it is checked than that particular user can add a quote_extra_no in quote module.
I tried the following. Added dependency for the quote module for the field.
$dictionary['Quote']['fields']['quote_extra_no'] = array (
'audited' => true,
'calculated' => false,
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'importable' => 'true',
'len' => '255',
'massupdate' => false,
'merge_filter' => 'disabled',
'name' => 'quote_extra_no',
'no_default' => true,
'reportable' => true,
'required' => false,
'size' => '50',
'source' => 'custom_fields',
'studio' => 'visible',
'type' => 'varchar',
'unified_search' => false,
'vname' => 'LBL_EXTRA_REF',
'dependency' => 'equal(related($assigned_user_link,"can_add_no"),"1")',
);
Also added the field in Editview. But its not working. If the current user can_add_no is set or checkbox is ticked. He can Edit the quote_extra_no in the editview of the quote.
How can i achive the functionality as the dependency is not helping me to do it.

There are two may to do that for both way you should have relation between both module.
By Using Dependency :
equal(related($related_field_name,"can_add_no"),"1")'
IN record.js write a method in that method call a api for canadd_no and according to that show hide the field.
API call Example :
app.api.call('read', app.api.buildURL(this.model.get('_module'), 'read', {id: this.model.get('id')}), null,
{
success: function(data) {
your costume code to hide
}
},
});
More Info related to API

Related

Symfony3 Tetranz/select2 - remote_route

I'm trying to use the select2entity-bundle for my project to implement auto-complete.
When using the builder, the specification is as follows :
$builder
->add('country', Select2EntityType::class, [
'multiple' => true,
'remote_route' => 'tetranz_test_default_countryquery',
'class' => '\Tetranz\TestBundle\Entity\Country',
'primary_key' => 'id',
'text_property' => 'name',
'minimum_input_length' => 2,
'page_limit' => 10,
'allow_clear' => true,
'delay' => 250,
'cache' => true,
'cache_timeout' => 60000, // if 'cache' is true
'language' => 'en',
'placeholder' => 'Select a country',
// 'object_manager' => $objectManager, // inject a custom object / entity manager
])
What should be specified within the 'remote_route' parameter?
Why should my field be linked to a route? How and where should this route be configured? Should it be linked to a query?
Thanks for your help!
The select needs to update the values to display while he user is typing. It does this by sending a request to a controller you need to write, which collects the relevant values and returns them as json.
Create a controller that returns the list of items to display in the select, and use the name of the route you defined for that controller as the 'remote_route' parameter.
The format for the returned data is documented halfway down the page for the bundle on github https://github.com/tetranz/select2entity-bundle

Magento 2 Attribute Not Show In Navigation

I have a problem when applying magento 2.1.9 to my project.
My attribute is ab_size
I have created that attribute with code blow.
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
foreach ($singleAttributeCodes as $key => $label) {
$categorySetup->removeAttribute($entityTypeId, $key);
$categorySetup->addAttribute(
$entityTypeId,
$key,
[
'type' => 'varchar',
'label' => $label,
'input' => 'select',
'required' => false,
'sort_order' => $sortOrder,
'visible' => true,
'user_defined' => true,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'filterable' => 0,
'visible_on_front' => true,
'used_in_product_listing' => true,
'group' => $group,
'apply_to' => 'simple,configurable,bundle,downloadable,grouped',
]
);
}
With config in the backend.
Enable filter (with result) done
Category Is Anchor done
Reindex done
Enable Category flat done
Enable Product flat done
Reindex all data done
Clear cache done
Use magento clean doesn't have any extension done
Check with attribute color (done it show in navigation)
Product Price Show
Category Show
about my system information
CentOS 7.0
Litespeed
Php7.0
Magento CE 2.1.9
I have debugged that the product collection buckets return empty
I think that problem with creating attribute code, has anyone got the same problem.
Thank anyone have tips.
With select attribute we must use type of int..
I think you have messed your attributes with this code.
Looking at it, it removes all the attributes and adds them but as type varchar, which may not be applicable to all attributes.
I would suggest resetting your Magento database, and then add the attribute using code like the following.
As I do not know what you are planning to use this attribute, some of the settings bellow may not apply to your use case.
$categorySetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'ab_size',
[
'type' => 'varchar',
'backend' => '',
'frontend' => '',
'label' => 'AB Size',
'input' => 'select',
'class' => '',
'source' => '',
'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 0,
'searchable' => false,
'filterable' => true,
'comparable' => false,
'visible_on_front' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => ''
]
);

How to reload a form from a drop down

I would like to reload the form, or preferably just the values, by using 'onChange'. There are several elements in the form that needs to be updated when changing the project id.
$this->addElement('select', 'project_id', array(
'label' => t('Project'),
'multiOptions' => $data,
'filters' => array('Int'),
'value' => 0,
'required' => true,
'disableTranslator' => true,
'validators' => array(),
'onChange' => 'Javascript:window.location.reload(false)'
));
You can change your onChange to call a custom javascript function instead - which will change any fields you need to change, and then submmit the form.

Defining multiple streams and adding fields to each of them in PyroCMS

I am new to PyroCMS and am willing to build a Job Site wherein there'll be 2 main users namely, Employers and Job Seekers. In order to allow them to register on the site, I'm using the Streams API from PyroCMS to build the forms. These users will be part of 2 different modules namely the Employer module and the Job Seeker module.
In the details.php file, under the install() function, I want to create multiple streams(database tables). The following code helps us to add a stream:
$this->streams->streams->add_stream();
The following code then helps us to define the fields to be added to the stream:
$this->streams->fields->add_fields($fields);
My concern is how do I add multiple streams like the above ones and add fields to each of them? In other words, how would the syntax
$this->streams->fields->add_fields($fields);
know which stream to add the fields to?
Have a look at the Fields Driver documentation for the Streams API. Fields and streams are separate entities, with no required association between the two. When adding a field you can assign it to a stream like this:
$field = array(
'name' => 'Question',
'slug' => 'question',
'namespace' => 'streams_sample',
'type' => 'text',
'extra' => array('max_length' => 200),
'assign' => 'STREAM_SLUG_GOES_HERE',
'title_column' => true,
'required' => true,
'unique' => true
);
$this->streams->fields->add_field($field);
Or you can create the streams and fields separately, and then assign each field to a stream like this:
$this->streams->fields->assign_field('streams_sample', 'STREAM_SLUG_GOES_HERE', 'question', array('required' => true));
All this talk of fields and streams makes me want to go outside...
You can add multiple streams like this example.
// Add banners streams
if ( ! $this->streams->streams->add_stream(lang('banner:banners'), 'banners', 'banner', 'banner_', null)) return false;
// Add groups streams
if ( ! $this->streams->streams->add_stream(lang('banner:groups'), 'groups', 'banner', 'banner_', null)) return false;
// Add some fields
$fields = array(
// BANNERS
array(
'name' => 'Banner Title',
'slug' => 'banner_title',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'text',
'extra' => array('max_length' => 200),
'title_column' => true,
'required' => true,
'unique' => true
),
// GROUPS
array(
'name' => 'Group Title',
'slug' => 'group_title',
'namespace' => 'banner',
'assign' => 'groups',
'type' => 'text',
'extra' => array('max_length' => 200),
'title_column' => true,
'required' => true,
'unique' => true
)
);
$this->streams->fields->add_fields($fields);

Magento adding attribute with option filterable (no results) through extension installation

I've searched around quite a bit for this answer and haven't been able to trace down the exact setting I need. I'm reaching out to see if anyone can help.
I'm writing a Magento extension to add some attributes to my installation. Everything is fine with the exception of one intricacy. I cannot set the attribute's "Use In Layered Navigation" property to "Filterable (no results)".
I can use the values in the attribute array in my installer file (below) to set that property to either "No" (0 value) or "Filterable (with results)" (1 value) but not without results.
Anyone have a suggestion of a property I may be missing or set incorrectly in my array?
Very much appreciated!
<?php
...
// Add the mm_framestyle attr. (filterable, non-super attr.)
$setup->addAttribute('catalog_product', 'mm_framestyle', array(
'backend' => 'eav/entity_attribute_backend_array',
'visible' => true,
'required' => false,
'user_defined' => true,
'searchable' => true,
'filterable' => true,
'comparable' => true,
'label' => 'Frame Types',
'group' => 'MyMaui Attributes',
'type' => 'varchar',
'input' => 'select',
'global' => false,
'option' => array (
'value' => array('maui_flex' => array('MAUI FLEX'),
'full_frame_metal' => array('FULL FRAME'),
'rimless_metal' => array('RIMLESS'),
'shields' => array('SHIELDS'),
)
),
'visible_on_front' => true,
'unique' => false
));
...
?>
To set the is_filterable property to "Filterable (no results)", your configuration array should have filterable set to 2.
If you wish to use an update script to change the previously-established setting, the syntax would be as follows:
$setup->updateAttribute('catalog_product', 'mm_framestyle', 'is_filterable', 2);

Categories