Why is there no factory for CheckBoxFieldWidget? - plone

The common approach for assign a widget to a field in Dexterity is something like that
form.widget(hours=DataGridFieldFactory)
hours = schema.List(title=u'Hours',?
default=hoursDefault,
value_type=DictRow(title=u'Hours', schema=IHours)
The Dexterity documentation mentions CheckBoxFieldWidget here:
http://plone.org/products/dexterity/documentation/manual/developer-manual/reference/widgets-1
However there is CheckBoxFieldWidgetFactory that could be used the same way for
form.widget(forProducts=checkbox.CheckBoxFieldWidget)
forProducts = schema.List(title=u'Products',
value_type=schema.Choice(source=productsVocabulary))
What is the right way for using the CheckBoxFieldWidget here?

CheckBoxFieldWidget is the factory for CheckBoxWidget. Did you encounter a problem using the code you provided above?

Related

How to use IdentityRoleClaim Table (IdentityRoleClaim<TKey> Class) in Identity in ASP.Net Core

I am trying to make the best use of Identity Core. In Identity, I am seeing, there are 7 tables like this-
In there, I am curious about this table-
Which can be found in here.
I am trying to use this table for claim based authentication where Super Admin can assign claims onto any role. So that Roles could be dynamic. So, what I am thinking is something like this-
But there is no table exists named Claim or close to this.
That is why I am thinking I have some gap in my knowledge. But there is no clear documentation known to me on this topic as far as I have found.
Can anyone please let me know,
How can I add an entry to the RoleClaim table?
Why there is no Claim table in Identity?
Is there any clear documentation regarding this?
I have found one close to my need, but I am not sure. The doc can be found in here and here.
Thanks in advance for helping.
Re-
If needed, my total code can be found in here.
1.How can I add an entry to the RoleClaim table?
var accountRole = await _roleManager.FindByNameAsync("Admin");
await _roleManager.AddClaimAsync(accountRole, new Claim("Manage", "Cashier"));
Reference:
https://stackoverflow.com/a/53332171/11398810
2.Why there is no Claim table in Identity?
This is by design.I think you need to raise question in github to ask for PG for help.
Reference:
https://github.com/dotnet/aspnetcore/issues
3.Is there any clear documentation regarding this?
There seems to be no official document to explain them.

how to write syntax for key value fair symfony console

I want to update inventory based on sku.
For example
php magento update_inventory --sku&quantity=array(1001,10) --sku&quantity=array(1002,20) --sku&quantity=array(1003,30)
But I’m not getting how to add options/arguments ?
here user at least need to provide one pair (sku& quantity).
for this i think i have to use ArrayInput class/InputArgument/InputOption.
Can you give some solution or reference to above requirement?
Have you looked at how Magento\Setup\Console\Command\AdminUserCreateCommand uses options? Take a look at how that code uses getOptionsList in the configure method. For your use case you may want to look into using InputOption::VALUE_IS_ARRAY
A good reference will be http://symfony.com/doc/current/components/console/introduction.html#using-command-options
You may also want to consider a different input format. For example using arguments instead of options and specifying the format in documentation.
php magento update_inventory 1001:10 1002:20 1003:30

Plone Conditional - If Content Type is Versionable

Is there a simple way to check if a content-type, or a specific object, has Versioning enabled/disabled in Plone (4.3.2)?
For context, I am making some unique conditionals around portal_actions. So instead of checking path('object/##iterate_control').checkout_allowed(), I need to first see if versioning is even enabled. Otherwise, the action in question does not display for items that have versioning disabled, because obviously it isn't checkout_allowed.
I didn't have any luck with good ole Google, and couldn't find this question anywhere here, so I hope it's not a dupe. Thanks!
I was able to get this working by creating a new script, importing getToolByName, and checking current content type against portal_repository.getVersionableContentTypes(). Then just included that script in the conditional.
I was looking for something like this that already existed, so if anyone knows of one let me know. Otherwise, I've got my own now. Thanks again!
The first thing that checkout_allowed does is check if the object in question supports versioning at all:
if not interfaces.IIterateAware.providedBy(context):
return False
(the interface being plone.app.iterate.interfaces.IIterateAware:
class IIterateAware( Interface ):
"""An object that can be used for check-in/check-out operations.
"""
The semantics Interface.providedBy(instance) are a bit unfortunate for usage in conditions or TAL scripts, because you'd need to import the interface, but there's a reversal helper:
context.portal_interface.objectImplements(context,
'plone.app.iterate.interfaces.IIterateAware')

what isCOMCLASS attribute and how is used

I was checking some code , I found comClass attribute.
what is that and what is it used for?
is there any good articles about that?
Thanks
Pretty easy to find, yeah... https://www.google.com/search?rlz=1C1CHFX_enUS384US384&sourceid=chrome&ie=UTF-8&q=ComClassAttribute
First link: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.comclassattribute.aspx
Fifth link: http://mikedimmick.blogspot.com/2005/09/what-does-vbnet-comclass-attribute-do.html
It seems to be relevant only to VB (as in, it's not relevant to C#, for example). See this:
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.comclassattribute.aspx
Also, I thought this was a good read: http://blogs.msdn.com/b/vbteam/archive/2007/06/01/so-what-does-lt-comclass-gt-actually-do.aspx; it basically says this is how you'd make a VB.NET class visible to VB6.
Other related threads that I found:
Will VB.NET automatically generate ComClass attribute and guids?
http://mikedimmick.blogspot.com/2005/09/what-does-vbnet-comclass-attribute-do.html

Custom formatter

I need to create a new custom formatter(using the module custom formatter) to replace some template code. So, for some fields, When I add a new custom formatter(field type: text) I need to print the title and the body. I tried to use $node->title but it doesn't work...
How can I do this? Probably using elements? And if yes...how?
Thanks in advance,
Regards,
Michele
Field formatters relate to the field that they are used for, it it's impossible to answer your question without know what field you are using (and it's contents).
To debug this, you could use the devel module and a bit of code. If you in your formatter write.
dpm(get_defined_vars());
this will give you a pretty printed list of all variables you have available. That should help you inspect and figure out how you get to what you need.
Custom formatters get's passed $element, if you do a dpm of $element (dpm($element) - If you have the Devel module installed) you will see the entire array, and notive that the $node object is passed as $element['#node'].
So with that said, to get to the node title you would use $element['#node']->title.
Please also not that it does say this on the help text of the custom formatters UI.

Resources