本文整理汇总了PHP中Symfony\Component\Form\Form::submit方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::submit方法的具体用法?PHP Form::submit怎么用?PHP Form::submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\Form
的用法示例。
在下文中一共展示了Form::submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
*
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$formData = $this->form->getData();
$name = (string) $formData->getName();
if ($name) {
$this->qb->andWhere($this->qb->expr()->like('p.name', ':name'))->setParameter('name', '%' . $name . '%');
}
$text = (string) $formData->getText();
if ($text) {
$this->qb->andWhere($this->qb->expr()->orx($this->qb->expr()->like('p.intro', ':intro'), $this->qb->expr()->like('p.content', ':content')))->setParameter('intro', '%' . $text . '%')->setParameter('content', '%' . $text . '%');
}
$isPublished = (string) $formData->getIsPublished();
if ($isPublished) {
if ($isPublished == 'yes') {
$this->qb->andWhere($this->qb->expr()->eq('p.status', ':status'))->setParameter('status', PostStatus::PUBLISHED);
}
if ($isPublished == 'no') {
$this->qb->andWhere($this->qb->expr()->neq('p.status', ':status'))->setParameter('status', PostStatus::PUBLISHED);
}
}
$order = (string) $formData->getOrder();
if ($order) {
$this->qb->orderBy('p.' . $order, 'DESC');
}
return true;
}
return false;
}
示例2: testValid
public function testValid()
{
$this->sut->submit(['fullName' => 'James T. Kirk', 'location' => 'San Francisco', 'placeOfBirth' => 'Iowa']);
foreach ($this->sut as $name => $child) {
$this->assertTrue($child->isValid(), $name);
}
$this->assertTrue($this->sut->isValid());
}
示例3: process
/**
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$query = $this->form->getData()->getQuery();
return true;
}
return false;
}
示例4: process
/**
*
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$this->entity = $this->form->getData();
$this->em->persist($this->entity);
$this->em->flush();
return true;
}
return false;
}
示例5: process
/**
*
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$formData = $this->form->getData();
if ($name = (string) $formData->name) {
$this->qb->andWhere($this->qb->expr()->like('t.name', ':name'))->setParameter('name', '%' . $name . '%');
}
return true;
}
return false;
}
示例6: process
/**
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$entityModel = $this->form->getData();
$this->entity->setContent($this->sanitizer->doClean($entityModel->getContent()));
$this->entity->setUserName($this->sanitizer->doClean($entityModel->getUserName()));
$this->entity->setUserEmail($this->sanitizer->doClean($entityModel->getUserEmail()));
$this->entity->setUserWeb($this->sanitizer->doClean($entityModel->getUserWeb()));
$this->em->persist($this->entity);
$this->em->flush();
return true;
}
return false;
}
示例7: process
/**
*
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$entityModel = $this->form->getData();
$file = $entityModel->getFile();
$fileName = $this->getName() . '.' . $file->getClientOriginalExtension();
$file->move($this->uploadPath, $fileName);
$this->entity->setFile($fileName);
$this->em->persist($this->entity);
$this->em->flush();
return true;
}
return false;
}
示例8: process
/**
* @param UserInterface $user
*
* @return bool
*/
public function process(UserInterface $user)
{
$this->form->setData($user);
if ('POST' == $this->request->getMethod()) {
$this->form->submit($this->request);
if ($this->form->isValid()) {
$this->onSuccess($user);
return true;
}
// Reloads the user to reset its username. This is needed when the
// username or password have been changed to avoid issues with the
// security layer.
$this->userManager->reloadUser($user);
}
return false;
}
示例9: handleForm
private function handleForm(Request $request, Form $form, $id, $command)
{
$form->submit($request);
if ($form->isValid()) {
$this->handleCommand($command);
return $this->redirectView($this->router->generate('get_game', array('id' => $id)), Codes::HTTP_CREATED);
}
return $form;
}
示例10: processForm
/**
* @param Request $request
* @param Form $form
*/
protected function processForm(Request $request, Form $form)
{
$data = json_decode($request->getContent(), true);
if ($data === null) {
$apiProblem = new ApiProblem(Response::HTTP_BAD_REQUEST, ApiProblem::TYPE_INVALID_REQUEST_BODY_FORMAT);
throw new ApiProblemException($apiProblem);
}
$clearMissing = $request->getMethod() !== 'PATCH';
$form->submit($data, $clearMissing);
}
示例11: process
/**
* Process current form
* @return boolean
*/
public function process()
{
$success = false;
if ($this->request->getMethod() == 'POST' || $this->request->getMethod() == 'PUT') {
// Correct HTTP method => try to process form
$this->form->submit($this->request);
if ($this->form->isValid()) {
// Form is valid => create or update the path
$this->data = $this->form->getData();
if ($this->request->getMethod() == 'POST') {
// Create path
$success = $this->create();
} else {
// Edit existing path
$success = $this->edit();
}
}
}
return $success;
}
示例12: process
/**
*
* @return boolean
*/
public function process()
{
$this->form->submit($this->request);
if ($this->form->isValid()) {
$formData = $this->form->getData();
if ($name = (string) $formData->name) {
$this->qb->andWhere($this->qb->expr()->like('l.name', ':name'))->setParameter('name', '%' . $name . '%');
}
if ($isPublished = (string) $formData->isPublished) {
if ($isPublished == 'yes') {
$this->qb->andWhere($this->qb->expr()->like('l.isPublished', ':isPublished'))->setParameter('isPublished', 1);
}
if ($isPublished == 'no') {
$this->qb->andWhere($this->qb->expr()->like('l.isPublished', ':isPublished'))->setParameter('isPublished', 0);
}
}
return true;
}
return false;
}
示例13: eventListener
/**
* Listen privet form
* @param Request $request
* @return bool
*/
private function eventListener(Request $request)
{
$this->rq = $request;
if ($request->isMethod("post")) {
$this->form->submit($this->rq);
if ($this->rq->isXmlHttpRequest()) {
$this->ajax = true;
}
return true;
}
return false;
}
示例14: validate
/**
* validate
*
* @param Form $form Form
* @param Request $request Request
*
* @return boolean
*/
public function validate(Form $form, Request $request)
{
if ($this->hasMethod($request->getMethod())) {
if ($request->getMethod() != 'POST') {
$form->submit($request);
} else {
$form->handleRequest($request);
}
return $form->isValid();
}
return false;
}
示例15: testDataIsInitializedFromSubmit
public function testDataIsInitializedFromSubmit()
{
$mock = $this->getMockBuilder('\\stdClass')->setMethods(array('preSetData', 'preSubmit'))->getMock();
$mock->expects($this->at(0))->method('preSetData');
$mock->expects($this->at(1))->method('preSubmit');
$config = new FormConfigBuilder('name', null, $this->dispatcher);
$config->addEventListener(FormEvents::PRE_SET_DATA, array($mock, 'preSetData'));
$config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit'));
$form = new Form($config);
// no call to setData() or similar where the object would be
// initialized otherwise
$form->submit('foobar');
}