[Form] Added valid attribute to a FormView
This commit is contained in:
parent
fc34ed1f86
commit
e92212ac13
@ -110,6 +110,7 @@ class FormType extends AbstractType
|
|||||||
->set('full_name', $fullName)
|
->set('full_name', $fullName)
|
||||||
->set('read_only', $readOnly)
|
->set('read_only', $readOnly)
|
||||||
->set('errors', $form->getErrors())
|
->set('errors', $form->getErrors())
|
||||||
|
->set('valid', $form->isBound() ? $form->isValid() : true)
|
||||||
->set('value', $form->getClientData())
|
->set('value', $form->getClientData())
|
||||||
->set('disabled', $form->isDisabled())
|
->set('disabled', $form->isDisabled())
|
||||||
->set('required', $form->isRequired())
|
->set('required', $form->isRequired())
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Form\Form;
|
|||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Tests\Fixtures\Author;
|
use Symfony\Component\Form\Tests\Fixtures\Author;
|
||||||
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
|
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
|
||||||
|
use Symfony\Component\Form\FormError;
|
||||||
|
|
||||||
class FormTest_AuthorWithoutRefSetter
|
class FormTest_AuthorWithoutRefSetter
|
||||||
{
|
{
|
||||||
@ -604,4 +605,20 @@ class FormTypeTest extends TypeTestCase
|
|||||||
$this->assertEquals(new PropertyPath('foo'), $form->getPropertyPath());
|
$this->assertEquals(new PropertyPath('foo'), $form->getPropertyPath());
|
||||||
$this->assertFalse($form->getConfig()->getMapped());
|
$this->assertFalse($form->getConfig()->getMapped());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testViewValidUnbound()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('form');
|
||||||
|
$view = $form->createView();
|
||||||
|
$this->assertTrue($view->get('valid'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testViewNotValidBound()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('form');
|
||||||
|
$form->bind(array());
|
||||||
|
$form->addError(new FormError('An error'));
|
||||||
|
$view = $form->createView();
|
||||||
|
$this->assertFalse($view->get('valid'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user