Symfony\Component\Form\PropertyPath::getIterator PHP Метод

getIterator() публичный Метод

Returns a new iterator for this path
public getIterator ( ) : Symfony\Component\Form\PropertyPathIterator
Результат Symfony\Component\Form\PropertyPathIterator
    public function getIterator()
    {
        return new PropertyPathIterator($this);
    }

Usage Example

Пример #1
0
    public function createAction()
    {
        // bind form to page model
        $page = new Page();
        $this->form->bind($this->request, $page);

        if ($this->form->isValid()) {

            try {

                // path for page
                $parent = $this->form->get('parent')->getData();
                $path = $parent . '/' . $page->name;

                // save page
                $this->dm->persist($page, $path);
                $this->dm->flush();

                // redirect with message
                $this->request->getSession()->setFlash('notice', 'Page created!');
                return $this->redirect($this->generateUrl('admin'));

            } catch (HTTPErrorException $e) {

                $path = new PropertyPath('name');
                $this->form->addError(new DataError('Name already in use.'), $path->getIterator());

            }
        }

        return $this->render('SandboxAdminBundle:Admin:create.html.twig', array('form' => $this->form));
    }
All Usage Examples Of Symfony\Component\Form\PropertyPath::getIterator