Skip to content

Instantly share code, notes, and snippets.

View basz's full-sized avatar

Bas Kamer basz

View GitHub Profile
/**
* @param \SndAdmin\Entity\UserRole $role
*/
public function setRole($role)
{
if ($role->getUser() != $this) {
$role->setUser($this);
}
$this->role = $role;
@basz
basz / solved
Created December 3, 2012 15:46
Have postcode validate only when country is known
<?php
namespace SndAdmin\Form;
use Zend\Form\Form;
use DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity;
use Zend\Form\Fieldset;
use Zend\Validator\Callback;
use Zend\I18n\Validator\PostCode;
class AddressFieldset extends Fieldset implements \Zend\InputFilter\InputFilterProviderInterface
{
"name": "bushbaby/project-sandalinos-website",
"description": "Sandalinos Website Project",
"authors": [
{
"name": "Bas Kamer",
"email": "bas@bushbaby.nl"
}
],
"keywords": [
if you upload a form with the form plugin suggested (ajax) and any file input's are posted as string and not as an array representing an not uploaded file.
You need to manually check for this, because the file input validator will fail on this an show an "Invalid type given. File array expected" error.
This is problematic if you try to implement partial forms (or non required file inputs).
I am not sure if you would consider this a limitation of the zf2.1 file filter as stricly speaking the validator is correct...
This fixes it;
@basz
basz / gist:4620278
Created January 24, 2013 11:23
nested FormElementManager
public function getFormElementConfig() {
return array(
'shared' => array(
),
'invokables' => array(
'SndAdmin\Form\FootpadComposeForm' /* does not need to be defined as it will be instanciated if not found */
),
'factories' => array(
'SndAdmin\Form\FootpadComposeFieldset' => function($sm) {
// 'SndAdmin\Service\Fieldset\FootpadComposeFactory' actually a class containing
[<c0142b17>] ? get_signal_to_deliver+0x1a7/0x3d0
[<c0108967>] ? __setup_frame+0x187/0x270
[<c0108cbf>] ? do_signal+0x8f/0x150
[<c01b2b06>] ? rw_verify_area+0x66/0x120
[<c011f2a1>] ? do_page_fault+0x161/0x3e0
[<c011e0e5>] ? pvclock_clocksource_read+0xf5/0x190
[<c0509508>] ? sys_socketcall+0x268/0x2c0
[<c0108dc8>] ? do_notify_resume+0x48/0x50
[<c068ff12>] ? work_notifysig+0x9/0xf
[<c0680000>] ? sctp_rcv_ootb+0x50/0xf0
protected $acceptCriteria = array(
'Zend\View\Model\JsonModel' => array(
'application/json',
'application/javascript'
),
'Zend\View\Model\ViewModel' => '*/*'
);
public someAction() {
"repositories":
[
{
"type": "git",
"url": "http://github.com/basz/SlmLocale"
},
],
@basz
basz / gist:4754686
Created February 11, 2013 14:26
pagination
<?php echo $this->paginationControl($this->paginator, 'sliding', 'snd-admin/interface/pagination', $this->viewModel()->getCurrent()->getVariables()); ?>
@basz
basz / gist:4945424
Last active December 13, 2015 17:09
<?php
namespace SndAdmin\Form;
use DoctrineModule\Stdlib\Hydrator\DoctrineObject;
use Zend\Form\Form;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;