Skip to content

Instantly share code, notes, and snippets.

@nclundsten
Created March 14, 2014 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nclundsten/9555417 to your computer and use it in GitHub Desktop.
Save nclundsten/9555417 to your computer and use it in GitHub Desktop.
<?php
$form = new \Zend\Form\Form;
$form->setInputFilter($formFilter = new \Zend\InputFilter\InputFilter());
$fieldSet = new \Zend\Form\FieldSet;
$fieldSet->setName('subforms');
$subForm = new \Zend\Form\Form;
$subForm->setName(0);
$subForm->add(array(
'name' => 'text',
'attributes' => array(
'type' => 'text'
),
));
$subForm->setInputFilter($subFormFilter = new \Zend\InputFilter\InputFilter());
$subFormFilter->add(array(
'name' => 'text',
'required' => true,
'allow_empty' => false,
));
$fieldSet->add($subForm);
$form->add($fieldSet);
$data = array(
//note that subforms[0][text] is required and im not passing it
);
$form->setData($data));
echo $form->isValid(); //true, should be false
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment