Skip to content

Instantly share code, notes, and snippets.

@Doopin
Doopin / gist:7c484da95cb8777bf3fb
Created December 21, 2014 16:49
Filter, Form, Validation
//My Filter Class
<?php
namespace Admeup\Form\FormValidator;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
'home' => array(
'type' => 'literal',
'options' => array(
'route' => '/project[/:project_id]/project-item',
'defaults' => array(
'controller' => 'Item\Controller\Index',
'action' => 'index',
),
'constraints' => array(
'project_id' => '[0-9]+'
$inputFilter->add($factory->createInput(array(
array(
'name' => 'birthday',
'validators' => array(
array(
'name' => 'Zend\Validator\Date',
'break_chain_on_failure' => true,
)
),
'filters' => array(
@Doopin
Doopin / gist:d639d045f6985b671f05
Created April 4, 2015 13:49
How to fix this On Select2 4 with Bootstrap 3.3.4
<div>
<div class="form-group">
<div class="col-sm-6">
<label class="control-label" for="gender"><?php echo ucfirst($this->translate('sexe')); ?></label>
<div class="input-group">
<span class="input-group-addon">
<span class="icomoon-mars"></span>
</span>
<select required class="select-without-search form-control" name="gender" data-fv-notempty
data-placeholder="Select gender"
@Doopin
Doopin / gist:74817920a3847c198332
Created April 8, 2015 16:02
Modify Select2 CSS
/*Put this CSS declaration in another file which will be loadeed after Select2 Css file*/
/* He we reset the border-radius only for a particular bloc */
#sign-up-form .select2-container .select2-selection--single {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
/* This css will force select2 box heigth to match with standard Bootstrap input element height*/
@Doopin
Doopin / gist:215cd04df2d48a425079
Created April 27, 2015 14:11
Validation not working for date format YYYY-MM
<div class="form-group">
<label for="startDate" class="col-xs-12 control-label">Start date</label>
<div class="col-xs-12">
<input id="startDate" required name="experience[startDate]" data-fv-notempty-message="date is required"
type="date" placeholder="YYYY-MM" class="form-control revalidate start-date input-sm single-date-picker-month"
data-fv-date="true" data-fv-date-separator="-" data-fv-date-format="YYYY-MM" data-fv-date-message="Invalid date"/>
</div>
</div>
@Doopin
Doopin / HydratingResultSet ZF2
Created May 13, 2015 14:57
How to reset HydratingResultSet for many iterations?
//In myMapper class, I have this method
public function loadAllPosts() {
$postObject = new Post();
$userObject = new User();
$select = new Select();
$select->from(['post' => $postObject->tableName()])
->join(['user' => $userObject->tableName()], 'post.user= user.id');
@Doopin
Doopin / add.php
Last active October 11, 2015 13:52
Csrf field validation always fails
<?php
//The form declaration Class
$this->add(array(
'type' => 'Csrf',
'name' => 'sec',
'options' => array(
'csrf_options' => array(
'timeout' => 600
)
)
@Doopin
Doopin / zf2.php
Created June 17, 2016 02:51
Configuration Issue ZF2
/*
* I have 4 modules which are well loaded
*/
// Action called
public function indexAction() {
$this->layout('layout/default');
return [
@Doopin
Doopin / settings.php
Last active June 23, 2016 12:24
ZF2 CSRF Field not working as expected
/*
* Hello Guys, going through something weird with ZF2 CSRF Field
* Please check this gist for my non-working settings
*/
// LoginForm.php
class LoginForm extends MainForm {
public function __construct($name = 'loginForm', $options = []) {