zend-framework2

Doctrine2 in ZF2 - DQL gives different result than findOneBy method

核能气质少年 提交于 2019-12-02 03:38:10
问题 I have this entity: /** * User state. * * @ORM\Entity(repositoryClass="User\Repository\StateRepository") * @ORM\Table(name="user_state") */ class State implements StateInterface { /** ONE-TO-ONE BIDIRECTIONAL, OWNING SIDE * @var User * @ORM\Id * @ORM\OneToOne(targetEntity="User\Entity\User", inversedBy="state") * @ORM\JoinColumn(name="user_id", referencedColumnName="id") */ protected $user; /** ONE-TO-ONE UNIDIRECTIONAL * @var \Application\Entity\State * @ORM\Id * @ORM\ManyToOne(targetEntity=

ZF2 form validation not working properly for email

99封情书 提交于 2019-12-02 01:50:53
问题 i have a input box with type="email" and validation it with zend validator <input type="email" name="email" > email </input> 'email' => array( 'required' => true, 'validators' => array( array( 'name' => 'Regex', 'options' => array( 'pattern'=>'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/', 'messages' => array( \Zend\Validator\Regex::NOT_MATCH=>'Please fill correct email ', ) ), 'break_chain_on_failure' => true ), ), problem is if i use another array to check for IS

ZF2 form validation not working properly for email

让人想犯罪 __ 提交于 2019-12-02 01:43:16
i have a input box with type="email" and validation it with zend validator <input type="email" name="email" > email </input> 'email' => array( 'required' => true, 'validators' => array( array( 'name' => 'Regex', 'options' => array( 'pattern'=>'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/', 'messages' => array( \Zend\Validator\Regex::NOT_MATCH=>'Please fill correct email ', ) ), 'break_chain_on_failure' => true ), ), problem is if i use another array to check for IS_EMPTY zend regex again does not display the above error instead display default zend regex error and

ZF2, how to create form view helper?

醉酒当歌 提交于 2019-12-02 00:28:37
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. Sam 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 array( 'invokables' => array( 'customViewHelperCallName' => 'Namespace\Form\View\Helper\Classname' ) );

How to get a $_POST request from view module?

拥有回忆 提交于 2019-12-02 00:08:35
I want to get the checkboxes from a table in a view module, but I can't get it to work. This is the table: <form action="" method="post"> <TABLE id="dt_basic" class="table table-striped table-bordered table-hover dataTable"> <THEAD> <TR> <TH></TH> <TH>ID</TH> <TH>Client</TH> <TH>User</TH> <TH>Role</TH> <TH>Projects</TH> </TR> </THEAD> <TBODY> <?php /* @var $item Admin\Model\User */ foreach ($this->users as $item) { ?> <TR> <TD class='admin'><input type="checkbox" name="users[<?php echo $item->id; ?>]" value=<?php echo $item->id; ?> checked/></TD> <TD class='admin c'><?= $item->id ?></TD> <TD

Doctrine2 in ZF2 - DQL gives different result than findOneBy method

只愿长相守 提交于 2019-12-02 00:04:21
I have this entity: /** * User state. * * @ORM\Entity(repositoryClass="User\Repository\StateRepository") * @ORM\Table(name="user_state") */ class State implements StateInterface { /** ONE-TO-ONE BIDIRECTIONAL, OWNING SIDE * @var User * @ORM\Id * @ORM\OneToOne(targetEntity="User\Entity\User", inversedBy="state") * @ORM\JoinColumn(name="user_id", referencedColumnName="id") */ protected $user; /** ONE-TO-ONE UNIDIRECTIONAL * @var \Application\Entity\State * @ORM\Id * @ORM\ManyToOne(targetEntity="Application\Entity\State", fetch="EAGER") * @ORM\JoinColumn(name="state_id", referencedColumnName="id"

Set layout variables for use by the (404) error pages in ZF2

我们两清 提交于 2019-12-01 23:39:26
At present I set a couple of variables to be used by the app's overall layout.phtml, using the onDispatch method of a BaseController, which all my other controllers extend: public function onDispatch(MvcEvent $e) { $config = $this->getServiceLocator()->get('config'); $this->layout()->setVariable('platformName', $config['platform']['name']); $this->layout()->setVariable('platformYear', $config['platform']['year']); } This works fine, until I test some error pages and find that these pages do not get provided with the variables, as it's not using the base controller. How can I get around this

Zend Framework 2: Getting an ordered SQL call

 ̄綄美尐妖づ 提交于 2019-12-01 23:23:18
问题 I've been trying to get an order ASC/DESC call for a field (let's say craeted), and I can't seem to figure out how to do it in ZF2. Where am I going wrong..? namespace Todo\Model; class TodoTable extends AbstractTableGateway { public function __construct(Adapter $adapter) { $this->adapter = $adapter; $this->resultSetPrototype = new ResultSet(); $this->resultSetPrototype->setArrayObjectPrototype(new Todo()); $this->initialize(); } public function fetchAll() { $resultSet = $this->select(array(

How to redirect to the login page with BjyAuthorize

佐手、 提交于 2019-12-01 22:50:00
问题 I want to redirect some pages to the login page instead of page 403. By default BjyAuthorize redirects everything to a 403 page. Is it possible to configure this behavior? I found this: RedirectionStrategy. How do I use this? 回答1: Finally I got it. With version 1.2.* of BjyAuthorize, you simply add in config/autoload/bjyauthorize.global.php : return array( 'bjyauthorize' => array( 'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy', // [...] ), ); And it will redirect you to

ZF2: How do I use InArray validator to validate Multiselect form element?

这一生的挚爱 提交于 2019-12-01 22:26:14
问题 I have a ZF2 form where I had to disable native validators, for a specific reason. Then, when adding elements programatically to the form I also add validators. One of the elements is a Multiselect array. $form->add( array( 'type' => 'Zend\Form\Element\Select', 'options' => array( ( 'label' => 'few items', 'value_options' => Array ( 'one' => 'one', 'two' => 'two', 'three' => 'three', 'four' => 'four', ) ), 'attributes' => array ( 'multiple' => 'multiple', 'value' => array('two','three'),