Zend Framework with PHP, changing class labels - php

I am using Zend Framework with Dojo to make tab containers. I need for the dt tags to be createEventForm-waiverDetail-addElement-label instead of addElement-label. However I cannot figure it out. You can see them as the id in the following code snippet
http://pastie.org/780362
I have looked and looked for this. I think it may be something in the decorators. The following is the decorators that I set for the Zend Dojo Form:
$this->setDecorators(
array(
'FormElements',
array(
'TabContainer',
array(
'id' => 'tabContainer',
'style' => 'width: 100%; height: 500px;',
'dijitParams' => array(
'tabPosition' => 'top'
),
),
),
'DijitForm',
)
);

For future users of the site that are looking for similar information. In order to do this you must reset the decorator stack, setting the id while you are doing it.

Related

One-to-Many Relationship type is not showing in Studio - SugarCRM

I am working in Sugarcrm 7.8 I am trying to create a relationship between contacts and my custom module example myorder but its not showing in type field when I select my custome module in `Related Module'.
I couldnt able to find any doc which explains such situation. How i can make a one-to-one relationship through studio when its not showingup. I really dont like to create through code as it breaks operations while we try to retrive report. If i work through studio its fine.
Any how i tried creating the follwing files to see if it shows any relationship.
src/custom/Extension/application/Ext/TableDictionary/contacts_myorder_1.php
src/custom/metadata/contacts_myorder_1MetaData.php
But it creates a new relationship via code.
Has anyone been able to achieve anything similar?
Community Question: https://community.sugarcrm.com/message/94195-one-to-many-relationship-type-is-not-showing-in-studio
After some deep research found that, In my custom module i should have explained the relationship between the modules.
After creating the follwoing file. I could able to see the relationships.
src/modules/mycustomodule/clients/base/layouts/subpanels/subpanels.php
src/modules/mycustomodule/vardefs.php
Content: subpanels.php
array (
'layout' => 'subpanel',
'label' => 'LBL_MYCUSTOMMODULE_SUBPANEL_CONTACTS',
'context' => array (
'link' => 'mycustommodule_contacts',
),
),
Content: vardefs.php
'mycustommodule_contacts' => array(
'name' => 'mycustommodule_contacts',
'type' => 'link',
'relationship' => 'contacts_mycustommodule',
'module' => 'Contacts',
'bean_name' => 'Contact',
'source' => 'non-db',
'vname' => 'LBL_MYCUSTOMMODULE_CONTACTS_LINK',
),
After Repair & Rebuild. It works as expected. Hope it helps someone.!

Multiple items with the same ID in the view - ZF2

I am building a web application using ZF2 and Doctrine. I have a view containing a base form to which the user can add multiple instances of a fieldset, the filedsets are added via HTML template and js cloning. We are making use of the Doctrine hydrator and cascade=persist to write to the dB. It is all working but I am concerned when the fieldsets are added it results in multiple items with the same ID which breaks w3 standards. Has anyone a solution or work around for this? Or would it be considered acceptable in this instance?
An example of one fieldset element:
$this->add(array(
'name' => 'glassAssemblyID',
'attributes' => array(
'type'=> 'hidden',
'id' => 'glassAssemblyID',
),
));
Many thanks
James
You should set the ID in JavaScript after cloning the element.
This is an easy one. Just just change your code to:
$this->add(array(
//'name' => 'glassAssemblyID',
'attributes' => array(
'type'=> 'hidden',
//'id' => 'glassAssemblyID',
),
));
No point in putting out an element id which is obviously not being used.
If you really feel you do need ids for some reason then put out something like EntityType-id for your ids.

Use spiffy navigation with zfcrbac module

I'm trying to understand how spiffy-navigation works. I integrate the module, it's working very well. I have my navigation.
But the doc says :
Rbac specific options
role: required The role to use to determine if access is granted.
permission: required The permission to use to determine if access is
granted.
But, even if i did something like that, it still not working.
'containers' => array(
'default' => array(
array(
'options' => array(
'label' => 'profil',
'route' => 'profil',
'role' => 'members',
'permission' => 'member'
),
'pages' => array(
// ...
)
)
)
),
EDIT(May 27) :
This is in fact a try of this discussion :ZF2 Generate navigation using zfcrbac zfcUser and hierarchical role strategy
My Question is the same :
How to generate a dynamic navigation, for a user wich can only see links that is granted to access ?
For example when you write this :
<?php echo $this->navigation('navigation')->menu()->setUlClass('nav navbar-nav')?>
In our layout in ZF2 without zfcRbac we can specify getAcl(), setAcl(), getRole() and setRole(), gets and sets ACL (Zend\Permissions\Acl) but with zfcRbac this didn't work.
Spiffy Navigation need to be improved for doing that(it's the prototype of zf3 navigation). It's not the aim of ZfcRbac module.
if someone has a solution it would be nice.

ZF2 empty output on underscore method

I've got an ZF2 application which is an extended skeletonapplication with a few extra modules like authentication and authorization, running on Zend Server comunity edition.
In order for poedit to find the strings it has to translate i use the _("string") method like so:
$this->add(array(
'name' => 'eaddress',
'type' => 'Zend\Form\Element\Text',
'attributes' => array(
'id' => 'eaddress',
'type' => 'email',
),
'options' => array(
'label' => _('EMAIL'),
),
));
But when I do that the application outputs nothing to the browser not even an error:
Firefox: The connection was reset
Chrome: No data received
Safari: {shows epmty page}
Does anyone know how to fix this?
Thanks in advance
As far as i know, you dont need to write any function in order to have ZF2 translating your literals. Actually it is working with poedit like a charm.
If you look at this manual page you will see how to easily translate stuff in your views, just using $this->translate(), and there is where actually you have to do it.
About forms labels, you dont even have to worry since the form view helpers already translate label if everything is well configured.
If you want to know more about poedit and zf2 you can go to this blog post or this great sams's post

How do I configure Dependency Injection in Zend Framework 2?

DISCLAIMER: I'm a complete noob to Zend.
I'm evaluating Zend Framework 2 at work, and trying to configure it to work with ZfTwig for templating. (See here: https://github.com/mtymek/ZfTwig)
I got through Step 3 of the config ok, but I can't figure out Step 4.
I tried placing the following in application.config, but no good.
Where am I supposed to put this?
return array(
'di' => array(
'instance' => array(
// setup other stuff...
// ...
// setup view script resolvers - very similar to configuration
// from ZendSkeletonApplication
'Zend\View\Resolver\AggregateResolver' => array(
'injections' => array(
'Zend\View\Resolver\TemplateMapResolver',
'ZfTwig\TemplatePathStack',
),
),
'Zend\View\Resolver\TemplateMapResolver' => array(
'parameters' => array(
'map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.twig',
),
),
),
'ZfTwig\TemplatePathStack' => array(
'parameters' => array(
'paths' => array(
'application' => __DIR__ . '/../view',
),
),
),
// Tell TwigRenderer how it should locate .twig files
'ZfTwig\TwigRenderer' => array(
'parameters' => array(
'resolver' => 'Zend\View\Resolver\AggregateResolver',
),
),
),
);
Google is no help... I can't find any documentation on Zend's site or anywhere telling me where this is supposed to go.
Thanks for the help!
The di configuration is from the first betas of Zend Framework 2. Zend\Di is a component still available, but internally (as with many other modules) replaced by Zend\ServiceManager.
Basically, both are able to provide dependency injection. Only for Zend\Di it can do this kind-of automatically and for Zend\ServiceManager there are other options to make dependency injection more explicit.
To give an answer to your question: ZfcTwig is now part of ZF-Commons and https://github.com/ZF-Commons/ZfcTwig is the location you have to search for now. Just for your insights, this file is an example of a factory used by the service manager. For more background of service managers in Zend Framework 2, I have written a blog post two months ago which might be interesting.

Categories