zend-framework2

ZF2, how to create form view helper?

◇◆丶佛笑我妖孽 提交于 2019-12-31 03:31:07
问题 I want to change the way ZF2 shows the form elements. I think I have to create my own view helper but I don't know how. I Googled for it but didn't find any useful resource. 回答1: See the SourceCode of existing Zend\Form\View\Helper* Basically you extend those and overwrite the required functions of stuff you want to modify. After that you'll need to register your very own view helper. This is easily done within Module.php's getViewHelperConfig() public function getViewHelperConfig() { return

Doctrine One-To-Many Relationship Won't Save - Integrity Constraint Violation

陌路散爱 提交于 2019-12-30 18:06:13
问题 I'm attempting to use Doctrine ORM Associations. I've read several tutorials and the online docs, but it's not working, and I'm honestly not sure what I'm doing wrong here. Seems like my experiments with Doctrine are pretty hit or miss. Any assistance would be appreciated. I'd like to have a User entity and UserHistory entity, which has multiple rows for a single User. That to me sounds like One-To-Many. I don't necessarily need it to be bidirectional. The problem I'm having is adding a

ReflectionException is thrown when mapping entities in Doctrine from different databases

佐手、 提交于 2019-12-30 13:26:13
问题 I'm trying to use Doctrine 2 in a ZF2 application which contains two modules, each with its own database. I need to use cross-database joins so that I can associate entities from one module with entities in another. Here's a UML diagram of the setup. I've tried using this in my first entity (I've removed irrelevant parameters and use statements): namespace Client\Entity; /** * A website. * * @ORM\Entity * @ORM\Table(name="users.website") * ... * @property $server */ class Website extends

PHPUnit with a Zend Framework 2 module

做~自己de王妃 提交于 2019-12-30 10:49:59
问题 I'm struggling in getting a PHPUnit test to work with ZF2. My directory structure looks as follows project - src - config, data, module, public, vendor - init_autoloader.php - test - bootstrap.php - SimpleTest.php The application itself works well. Now for running PHPUnit tests, my bootstrap.php looks as follows putenv('ZF2=../src/vendor/zendframework/zendframework/library'); $loader = include '../src/vendor/autoload.php'; include '../src/init_autoloader.php'; This works for ZF2 related

Button content in ZF2 forms

こ雲淡風輕ζ 提交于 2019-12-30 10:27:15
问题 How to edit the button content of a Button element (of a ZF2 form)? I can set a label, but i would like to insert some html code inside it. $this->add(array( 'type' => 'Button', 'name' => 'submit', 'options' => array( 'label' => 'Modifica', ), 'attributes' => array( 'type' => 'submit', 'class' => 'btn btn-warning' ) )); Thanks 回答1: You can simply use the disable_html_escape label's option. It works for me. $this->add(array( 'type' => 'Button', 'name' => 'submit', 'options' => array( 'label' =

How to use cookie in Zend Framework 2? [closed]

廉价感情. 提交于 2019-12-30 07:40:25
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I cant understand how to use cookies in ZF2? Can some one advise some links with set and get cookie? 回答1: simply use the rememberMe() method on the SessionManager to set a cookie See SessionManager Code on line

Zend Framework 2 - BjyAuthorize always denies access

邮差的信 提交于 2019-12-30 04:31:28
问题 I have setup the bjyoungblood/bjy-authorize module, but I am currently getting a 403 "access denied" error for each URL except for the one configured in the home route. My module.byjauthorize.global.php looks like following: 'bjyauthorize' => array( 'guards' => array( 'BjyAuthorize\Guard\Controller' => array( array('controller' => 'index', 'action' => 'index', 'roles' => array('guest','user')), array('controller' => 'index', 'action' => 'stuff', 'roles' => array('user')), array('controller' =

Zend Framework 2 - translating routes

╄→尐↘猪︶ㄣ 提交于 2019-12-30 03:42:06
问题 I am wondering if it is possible to use translational tools for routes/uris in zf2. I want for example the route en.domain.tld/article/show/1 to translate for example to de.domain.tld/artikel/anzeigen/1 . I don't think regex is the way to go here, because it could result in something like en.domain.tld/artikel/show/1 . Also I want to avoid creating routes for every language, because it is going to get quite messy as the system scales. 回答1: I was able to get it working! First, add a 'router

select union in zf2 query

不打扰是莪最后的温柔 提交于 2019-12-30 03:41:47
问题 I am moving my web application from zf1 to zf2 and among the problems I have with sql queries, I can't figure out how to make a union. I used to be able to make $select->union($select1, $select2, $select3) but the Zend\Db\Sql\Select does not have an union() method anymore. Is there still a way to make an union in a query with zf2? 回答1: I use this https://github.com/zendframework/zf2/pull/3962. (union of two select queries). Just to complete this answer, I use this to combine/union of 3

How to render a mail template with layout in ZF2?

北城以北 提交于 2019-12-30 03:09:07
问题 In the ZF1 I used the following code to render a mail body: // View erstellen $view = new Zend_View(); // Layout erstellen $layout = new Zend_Layout(); // HelperPath muss hier nochmals übergeben werden da es ein neues View Objekt ist. $view->addHelperPath('Own/View/Helper', "Own_View_Helper_"); // ViewScript $view->setScriptPath(APPLICATION_PATH . '/views/scripts/emails/'); // LayoutPath $layout->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/'); $layout->setLayout('layoutMail'); $layout-