Problems converting a INI based configuration into YAML - zend-form

Greetings to all.
I am working on a project that uses Zend_Config to create forms. I am working on broadening my knowledge base and have hit a snag.
I have a form config file in ini format that works fine. I would like to convert that form configuration into a YAML based file. I attempted to write the conversion myself, and though I accounted for everything. As this is my first journey into yaml, I need help to see what is wrong.
The ini file that works is here:
[production]
;General From Meta Data
logon.form.action = "/customers/plogin"
logon.form.method="post"
logon.form.id="loginform"
;Form Element Prefix Data
logon.form.elementPrefixPath.decorator.prefix = "Elite_Decorator_"
logon.form.elementPrefixPath.decorator.path = "Elite/Decorator/"
logon.form.elementPrefixPath.decorator.type = "decorator"
logon.form.elementPrefixPath.validate.prefix = "Elite_Validate_"
logon.form.elementPrefixPath.validate.path = "Elite/Validate/"
logon.form.elementPrefixPath.validate.type = "validate"
;Form Element - email
logon.form.elements.email.type = "text"
logon.form.elements.email.options.required = "true"
logon.form.elements.email.options.label = "Email"
logon.form.elements.email.options.decorators.composite.decorator = "Composite"
logon.form.elements.email.options.validators.strlen.validator = "StringLength"
logon.form.elements.email.options.validators.strlen.options.min="2"
logon.form.elements.email.options.validators.strlen.options.max="50"
;Form Element - Password
logon.form.elements.password.type = "password"
logon.form.elements.password.options.required = "true"
logon.form.elements.password.options.label = "Password"
logon.form.elements.password.options.decorators.composite.decorator = "Composite"
logon.form.elements.password.options.validators.strlen.validator = "StringLength"
logon.form.elements.password.options.validators.strlen.options.min="2"
logon.form.elements.password.options.validators.strlen.options.max="20"
;Form Element - Submit
logon.form.elements.submit.type = "submit"
logon.form.elements.submit.options.label = "Logon"
;Form Display Group 1
logon.form.displaygroups.group1.name = "logon"
logon.form.displaygroups.group1.options.legend = "Please Login to your Account"
logon.form.displaygroups.group1.options.decorators.formelements.decorator = "FormElements"
logon.form.displaygroups.group1.options.decorators.fieldset.decorator = "Fieldset"
logon.form.displaygroups.group1.options.decorators.fieldset.options.style = "width:375px;"
logon.form.displaygroups.group1.elements.email = "email"
logon.form.displaygroups.group1.elements.password = "password"
logon.form.displaygroups.group1.elements.submit = "submit"
And my YAML translation:
production:
logon:
form:
action: /customers/plogin
method: post
id: loginform
elementPrefixPath:
decorator:
prefix: Elite_Decorator_
path: Elite/Decorator/
type: decorator
validate:
prefix: Elite_Validate_
path: Elite/Validate/
type: validate
elements:
email:
type: text
options:
required: true
label: Email
decorators:
composite:
decorator: Composite
validators:
strlen:
validator: StringLength
options:
min: 2
max: 50
password:
type: text
options:
required: true
label: Password
decorators:
composite:
decorator: Composite
validators:
strlen:
validator: StringLength
options:
min: 2
max: 20
submit:
type: submit
options:
label: Logon
displaygroups:
group1:
name: logon
options:
legend: Please login to your account
decorators:
formelements:
decorator: FormElements
fieldset:
decorator: Fieldset
options:
style: width:375px;
elements:
email: email
password: password
submit: submit
The YAML based form only gives me a blank page. Upon investigation, none of the form markup is included in the page that is output. Any help would be greatly appreciated.
Regards,
Troy

I think you should have better indentation in your code:
production:
logon:
form:
action: /customers/plogin
method: post
....

Related

How to change resource way , to support multiple future instances in Raml like city and airport?

/{ca}/{en}/{v1}:
uriParameters:
ca:
description: Country of users have to specify with two letter country code.
type: string
required: true
minLength: 2
maxLength: 2
en:
description: Language have to specified either English or French.
enum: [en,fr]
type: string
required: true
v1:
description: The version of the API need to be either v1 or v2.
enum: [v1,v2]
type: string
required: true

How to define an example request body containing an array of complex objects in Swagger?

I am trying to write the Swagger spec for a service that posts an array of objects as request body. I would like the user to be able to test the service with a specific set of multiple different complex objects in the array as the default sample inputs.
So far I have the following code defining the service and complex object:
paths:
/myService
post:
summary: test 123
description: test 123
parameters:
- name: bodyParamsObject
description: 'Object containing any / all params in the body'
in: body
required: true
schema:
properties:
data:
$ref: '#/definitions/myInputArray'
responses:
200:
description: OK
schema: myOutputArray
definitions:
myInputArray:
type: array
items:
$ref: '#/definitions/myComplexObject'
myOutputArray:
type: array
items:
$ref: '#/definitions/myComplexObject'
myComplexObject:
type: object
properties:
description:
type: string
example: 'Example Item'
size:
example: 552
type: integer
format: int32
hasAdditionalProperties:
type: boolean
example: true
The output array is coming back correctly, but there is only one item in the model schema.
How can I make the sample request body contain multiple different items in the array?
I was able to solve this by using the example property on the object definition and filling it with the array in json.
definitions:
myInputArray:
type: array
items:
$ref: '#/definitions/myComplexObject'
example: [
{
"description": "Example Item 1",
"hasAdditionalProperties": true,
"size": 750,
},
{
"description": "Another example",
"hasAdditionalProperties": false,
"size": -22,
},
{
"description": "Last one",
"hasAdditionalProperties": true,
"size": 0,
}
]
myComplexObject:
type: object
properties:
description:
type: string
example: 'Example Item'
size:
example: 552
type: integer
format: int32
hasAdditionalProperties:
type: boolean
example: true

Module Hook to add extra field in drupal 8 content types

I want to add an extra field in Drupal 8 content types with a custom module and I am not getting any hook to do.
Below is the hook I am using but that is not helping me with the result I want :
function nodeclass_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
// Add a property only to nodes of the 'article' bundle.
if ($entity_type->id() == 'node' && $bundle == 'article') {
$fields = array();
$fields['mymodule_text_more'] = BaseFieldDefinition::create('string')
->setLabel(t('More text'))
->setComputed(TRUE)
->setClass('\Drupal\mymodule\EntityComputedMoreText');
return $fields;
}
}
Inside your module folder, create the below folders
modules/my_module/config/install/
Then create the below files inside your module folder.
my_module/config/install/field.field.node.article.field_text_more.yml
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_text_more
- node.type.article
id: node.article.field_text_more
field_name: field_text_more
entity_type: node
bundle: article
label: 'More text'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
my_module/config/install/field.storage.node.field_text_more.yml
langcode: en
status: true
dependencies:
module:
- node
id: node.field_text_more
field_name: field_text_more
entity_type: node
type: string
settings:
max_length: 255
is_ascii: false
case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Then re-install your module, it will add the new field "More text" into "Article" content type.
Note: Change file name and update the line "bundle: article" in field.field.node.article.field_text_more.yml if you wish to add fields to any other content type.

dojo FilteringSelect avoid Accented characters

I'm using a FilteringSelect that use an FilteringSelect as store.
I want to ignore the accented characters that users can enter, and to return all the elements with or without accents. But i don't know what event i have to catch.
Here's my code :
var ccppMemory = new dojo.store.FilteringSelect({
data: centrosPoblado,
idProperty: "id"
});
sboMunicipio = new dijit.form.FilteringSelect({
id: "soMunicipioSelect",
hasDownArrow: false,
placeholder: i18n.tools.searches.ordinary.departmentTown,
store: ccppMemory,
searchAttr: "unitario",
intermediateChanges : true,
queryExpr: "*${0}*",
autoComplete: false,
highlightMatch: "all",
style:"margin-right:5px;width:170px;"
}, "soMunicipioSelect");
sboMunicipio.startup();
To explain better, centrosPoblado is an array that i populate as :
centrosPoblado.push({
id: value.attributes.CODIGO_DANE,
label: value.attributes.NOMBRE_CENTRO_POBLADO,
unitario: value.attributes.DEPTO + " / " + value.attributes.NOMBRE_CENTRO_POBLADO
});
In 'unitario' i have store strings like 'Medellín', ' Bogotá', ....
What i want is that when a user enter medellín, the filterselect ignore and returns 'Medellín' . So what i think i have to do it's to substitute medellin for something like m[eé]d[eé]ll[íi]n, but i don't know where.
Thanks
if anyone is interested, here is the answer :
http://dojo-toolkit.33424.n3.nabble.com/FilteringSelect-avoid-Accented-characters-td4004099.html
You have to overwrite the 'queryEngine' of the Memory that its linked to the FilteringSelect

the keyAttr of data-dojo-props doesn't work

here is my html file :
...
<span data-dojo-id="staffStore" data-dojo-type="dojo.data.ItemFileReadStore" data-dojo-props='data:../../staff.json'></span>
<input data-dojo-type="dijit.form.ComboBox"
data-dojo-props="store: staffStore,
keyAttr: 'id',
searchAttr: 'staff_name',
autoComplete: true,
id: 'staff_name',
name:'staff_name',
value: '' "/>
...
and the json data goes as follows:
{
identifier: "id";,
label: "id",
items: [{id: 982483700, staff_name: "guanyu";},{id: 582057769, staff_name: "zhangfei";},{id: 166802994, staff_name: "zhaoyun";}]
}
here is my problem:
when i use post method i have got 'staff_name' in the searchAttr: 'staff_name' passed to the background-appication ,but i want to have the 'id' in the keyAttr: 'id' passed to background-application.in a word,i have passed made a wrong post action.can someone help me get out of this problem?
Use dijit/form/FilteringSelect not dijit/form/ComboBox.
You can enter any text into a ComboBox therefore it cannot return id which is the reason it returns text (or label or searchAttr). FilteringSelect allows only to chose one of options and therefore it can return id, which it does.
See it in action and experiment at jsFiddle: http://jsfiddle.net/phusick/QzQ38/