Submit the contact form.

@return \Illuminate\Http\Response
557078
public function postSubmit()
    {
        $rules = [
            'first_name' => 'required',
            'last_name'  => 'required',
            'email'      => 'required',
            'message'    => 'required',
        ];

        $input = Binput::only(array_keys($rules));

        $val = Validator::make($input, $rules);

        if ($val->fails()) {
            return Redirect::to($this->path)->withInput()->withErrors($val);
        }

        $this->throttler->hit();

        Mailer::send($input['first_name'], $input['last_name'], $input['email'], $input['message']);

        return Redirect::to('/')->with('success', 'Your message was sent successfully. Thank you for contacting us.');
    }
1197630
public function execute()
    {
        $form = $this->formFactory->createNamed('', $this->type, $this->object);
        $form->handleRequest($this->stack->getCurrentRequest());

        if ($form->isValid()) {
            $this->postUpdate($this->object);

            return $this->object;
        }

        return $form;
    }
954791
public function form()
    {
        return Administrator::form(function (Form $form) {
            $form->mobile('mobile', trans('merchant.mobile'))->rules('required');
            $form->email('email', trans('merchant.email'))->default('');
            $form->text('name', trans('merchant.name'))->rules('required');
            $form->image('avatar', trans('merchant.avatar'));
            $form->password('password', trans('merchant.password'))->rules('required|confirmed');
            $form->password('password_confirmation', trans('merchant.password_confirmation'))->rules('required')
                ->default(function ($form) {
                    return $form->model()->password;
                });

            $form->ignore(['password_confirmation']);
            $form->multipleSelect('roles', trans('merchant.roles'))->options(Role::all()->pluck('name', 'id'));
            $form->multipleSelect('permissions', trans('merchant.permissions'))->options(Permission::all()->pluck('name', 'id'));
            $form->display('created_at', trans('merchant.created_at'));
            $form->display('updated_at', trans('merchant.updated_at'));
            $form->hidden('merchant_id');

            $form->saving(function (Form $form) {
                $form->merchant_id = auth('merchant')->user()->merchant_id;
                if ($form->password && $form->model()->password != $form->password) {
                    $form->password = bcrypt($form->password);
                }
            });
        });
    }
1172552
public function post()
	{
		$originalProps = $this->props;
		if (ET_Util::isAssoc($this->props)){			
			$this->props["Fields"] = array("Field"=>array());		
			if (!is_null($this->columns) && is_array($this->columns)){
				foreach ($this->columns as $column){
					array_push($this->props['Fields']['Field'], $column);
				}	
			}							
		} else {
			$newProps = array();
			foreach ($this->props as $DE) {
				$newDE = $DE;
				$newDE["Fields"] = array("Field"=>array());
				if (!is_null($DE['columns']) && is_array($DE['columns'])){
					foreach ($DE['columns'] as $column){
						array_push($newDE['Fields']['Field'], $column);
					}						
				}
				array_push($newProps, $newDE);
			}
			$this->props = $newProps;					
		}
		
		$response = parent::post();
		
		$this->props = $originalProps;
		return $response;
	}
4276
public function form()
    {
        $permissionModel = config('admin.database.permissions_model');

        $form = new Form(new $permissionModel());

        $form->display('id', 'ID');

        $form->text('slug', trans('admin.slug'))->rules('required');
        $form->text('name', trans('admin.name'))->rules('required');

        $form->multipleSelect('http_method', trans('admin.http.method'))
            ->options($this->getHttpMethodsOptions())
            ->help(trans('admin.all_methods_if_empty'));
        $form->textarea('http_path', trans('admin.http.path'));

        $form->display('created_at', trans('admin.created_at'));
        $form->display('updated_at', trans('admin.updated_at'));

        return $form;
    }
1058375
public function handler(): Response
    {
        $data = $this->validate([
            'email' => [
                new Email()
            ],
            'phone' => []
        ]);
        $member = Member::search($this->getParameter('username'));
        if (!$member) {
            throw new HttpNotFoundException();
        }
        $member->update($data);
        $this->log('info', 'Update member [' . $member->getUsername() . ']');
        return response();
    }
789454
public function validate()
    {
        foreach($this->rules() as $key => $value) {
            $this->rules[$key] =  [$this->input($key), $value];
        }

        $validate = $this->validator->validate($this->rules);

        if ($validate->fails()) {
            if($this->isAjax()) {
                return $this->response->json(['errors' => $validate->errors()->all()], 403);
            }

            return $this->redirect->backWith('errors', $validate->errors()->all());
        }
    }
18851
public function callbackSubmit()
    {
        $id = $this->form->value("id");
        $this->di->get("userService")->deleteUser($id);
        $this->di->get("utils")->redirect("admin");
    }
1293325
public function postAction(Request $request)
    {
        try {
            $this->checkArguments($request);
            $contact = $this->getContactManager()->save(
                $request->request->all()
            );
            $apiContact = $this->getContactManager()->getContact(
                $contact,
                $this->getLocale($request)
            );
            $view = $this->view($apiContact, 200);
            $context = new Context();
            $context->setGroups(static::$contactSerializationGroups);
            $view->setContext($context);
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (MissingArgumentException $maex) {
            $view = $this->view($maex->toArray(), 400);
        } catch (RestException $re) {
            $view = $this->view($re->toArray(), 400);
        }

        return $this->handleView($view);
    }
1194504
public function indexAction()
        {

            $id = $this->getUser()->getId();

            /** @var User $oUser */
            $oUser = UserQuery::create()->findOneById($id);

            $form = $this->createFormBuilder($oUser)
                ->setAction($this->generateUrl("notification_center_update"))
                ->add('notification_change', 'checkbox')
                ->add('notification_error', 'checkbox')
                ->add('save', 'submit', array('label' => $this->get('translator')->trans('notificationcenter.form.save')))
                ->getForm();


            return $this->render('SlashworksAppBundle:NotificationCenter:index.html.twig', array(
                'user' => $oUser,
                'form' => $form->createView()
            ));
        }
975344
public function updateAction()
    {
        $form = $this->createForm(BasketType::class, $this->get('sonata.basket'), ['validation_groups' => ['elements']]);
        $form->handleRequest($this->getCurrentRequest());

        if ($form->isValid()) {
            $basket = $form->getData();
            $basket->reset(false); // remove delivery and payment information
            $basket->clean(); // clean the basket

            // update the basket
            $this->get('sonata.basket.factory')->save($basket);

            return new RedirectResponse($this->generateUrl('sonata_basket_index'));
        }

        return $this->forward('SonataBasketBundle:Basket:index', [
            'form' => $form,
        ]);
    }
462444
public function callbackSubmit()
    {
        // Get values from the submitted form
        $username       = $this->form->value("username");
        $password       = $this->form->value("password");

        // Connect to databse and se if user exists and if so compare password
        $user = new User();
        $user->setDb($this->di->get("db"));
        $res = $user->verifyPassword($username, $password);

        if (!$res) {
            $this->form->rememberValues();
            $this->form->addOutput("User or password did not match.");
            return false;
        }

        // Get the user
        $user->find("username", $username);

        // Check if user is deleted
        if (isset($user->deleted)) {
            $this->form->rememberValues();
            $this->form->addOutput("User is inactive. Contact administrator.");
            return false;
        }

        // Save user to session
        $this->di->get("session")->set("user_id", $user->id);
        $this->di->get("session")->set("username", $user->username);
        $this->di->get("session")->set("user_role", $user->role);

        // Redirect to profile page
        $this->di->get("response")->redirect($this->di->get("url")->create("comment"));
    }
980587
public function send()
    {
        // The URI has already been overriden (if applicable) by this point.
        $uri = isset($this->request->url) ? $this->request->url : null;
        if ($this->test && !empty($this->request->testUrl)) {
            $uri = $this->request->testUrl;
        }
        $uri = trim($this->renderTokens($uri));
        if (empty($uri)) {
            throw new ContactClientException(
                'No URL was specified for an API operation.',
                0,
                null,
                Stat::TYPE_ERROR,
                false
            );
        }

        $this->setLogs($uri, 'uri');

        $request   = $this->request;
        $transport = $this->transport;
        $options   = [];
        $manual    = isset($request->manual)
            && $request->manual
            && isset($request->template)
            && !empty(trim($request->template));

        // Retrieve/filter/tokenize the Request Body Field values if present.
        $requestFields = [];
        if (!$manual && !empty($request->body) && !is_string($request->body)) {
            $requestFields = $this->fieldValues($request->body);
        }
        $requestFormat = strtolower(isset($request->format) ? $request->format : 'form');
        $this->setLogs($requestFormat, 'format');
        switch ($requestFormat) {
            case 'form':
            default:
                $options['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';
                if ($requestFields) {
                    $options['form_params'] = $requestFields;
                }
                break;

            case 'json':
                $options['headers']['Content-Type'] = 'application/json; charset=utf-8';
                if ($requestFields) {
                    $options['json'] = $requestFields;
                }
                break;

            case 'text':
                $options['headers']['Content-Type'] = 'text/plain; charset=utf-8';
                if ($requestFields) {
                    // User specified to send raw text, but used key value pairs.
                    // We will present this as YAML, since it's the most text-like response.
                    $yaml = Yaml::dump($requestFields);
                    if ($yaml) {
                        $options['body'] = $yaml;
                    }
                }
                break;

            case 'xml':
                $options['headers']['Content-Type'] = 'application/xml; charset=utf-8';
                if ($requestFields) {
                    $doc                     = new DomDocument('1.0');
                    $doc->preserveWhiteSpace = false;
                    $doc->formatOutput       = true;
                    $root                    = $doc->createElement(self::XML_ROOT_ELEM);
                    $doc->appendChild($root);
                    foreach ($requestFields as $key => $value) {
                        $element = $doc->createElement($key);
                        $element->appendChild(
                            $doc->createTextNode($value)
                        );
                        $root->appendChild($element);
                    }
                    $xml = $doc->saveXML();
                    if ($xml) {
                        $options['body'] = $xml;
                    }
                }
                break;

            case 'yaml':
                $options['headers']['Content-Type'] = 'application/x-yaml; charset=utf-8';
                if ($requestFields) {
                    $yaml = Yaml::dump($requestFields);
                    if ($yaml) {
                        $options['body'] = $yaml;
                    }
                }
                break;
        }

        // Add the manual template if provided and manual mode is enabled.
        if ($manual) {
            $templateFields = $this->templateFieldValues($request->body);
            $body           = $this->renderTokens($request->template, $templateFields);
            if (!empty(trim($body))) {
                $options['body'] = $body;
                // Prevent double-encoding JSON.
                unset($options['json']);
            }
        } else {
            if (is_string($request->body) && !empty(trim($request->body))) {
                // For backward compatibility, support body as a string.
                $body = $this->renderTokens($request->body);
                if (!empty(trim($body))) {
                    $options['body'] = $body;
                }
            }
        }

        // Header Field overrides.
        if (!empty($request->headers)) {
            $headers = $this->fieldValues($request->headers);
            if (!empty($headers)) {
                if (isset($options['headers'])) {
                    $options['headers'] = array_merge($options['headers'], $headers);
                } else {
                    $options['headers'] = $headers;
                }
            }
        }

        $method = trim(strtolower(isset($request->method) ? $request->method : 'post'));
        $this->setLogs($method, 'method');
        $startTime = microtime(true);
        switch ($method) {
            case 'delete':
                $this->setLogs($options, 'options');
                $transport->delete($uri, $options);
                break;

            case 'get':
                if ($requestFields) {
                    $options['query'] = $requestFields;
                    // GET will not typically support form params in addition.
                    unset($options['form_params']);
                }
                $this->setLogs($options, 'options');
                $transport->get($uri, $options);
                break;

            case 'head':
                $this->setLogs($options, 'options');
                $transport->head($uri, $options);
                break;

            case 'patch':
                $this->setLogs($options, 'options');
                $transport->patch($uri, $options);
                break;

            case 'post':
            default:
                $this->setLogs($options, 'options');
                $transport->post($uri, $options);
                break;

            case 'put':
                $this->setLogs($options, 'options');
                $transport->put($uri, $options);
                break;
        }
        $transportRecords = $transport->getRecords();
        if ($transportRecords) {
            $debug = [];
            foreach ($transportRecords as $transportRecord) {
                if (
                    isset($transportRecord['channel'])
                    && 'guzzle.to.curl' == $transportRecord['channel']
                    && isset($transportRecord['message'])
                ) {
                    $debug[] = $transportRecord['message'];
                }
            }
            if ($debug) {
                $this->setLogs($debug, 'debug');
            }
        }
        $this->setLogs(microtime(true) - $startTime, 'duration');
        if ($this->test) {
            $this->setLogs($this->tokenHelper->getContext(true), 'availableTokens');
        }
    }
818344
public function actionSubmit()
    {
        $rr = new RequestResponse();

        if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
            if (\Yii::$app->request->post('sx-model') && \Yii::$app->request->post('sx-model-value')) {
                $modelClass = \Yii::$app->request->post('sx-model');
                $modelValue = \Yii::$app->request->post('sx-model-value');
                /**
                 * @var RelatedElementModel    $modelForm
                 * @var Form2FormSend          $modelFormSend
                 * @var RelatedPropertiesModel $validateModel
                 * @var Form2Form              $modelForm
                 */
                $modelForm = $modelClass::find()->where(['id' => $modelValue])->one();
                $modelFormSend = $modelForm->createModelFormSend();
                $modelFormSend->cms_site_id = \Yii::$app->cms->site->id;
                $modelFormSend->utms = (array)\Yii::$app->seo->utms;
                $modelFormSend->page_url = \Yii::$app->request->referrer;

                $validateModel = $modelFormSend->relatedPropertiesModel;

                $modelFormSend->data_values = $validateModel->toArray($validateModel->attributes());
                $modelFormSend->data_labels = $validateModel->attributeLabels();
                $modelFormSend->emails = $modelForm->emails;
                $modelFormSend->phones = $modelForm->phones;


                if ($validateModel->load(\Yii::$app->request->post()) && $validateModel->validate()) {
                    if ($this->_beforeSave($modelForm, $validateModel, $modelFormSend)) {
                        if (!$modelFormSend->save()) {
                            $rr->success = false;
                            $rr->message = \Yii::t('skeeks/form2/app', 'Failed to send the form');
                            return (array)$rr;
                        }

                        $validateModel->save();
                        $modelFormSend->notify();

                        $this->_afterSave($modelForm, $validateModel, $modelFormSend);

                        $rr->success = true;
                        $rr->message = \Yii::t('skeeks/form2/app', 'Successfully sent');
                    } else {
                        $rr->success = false;
                        $rr->message = \Yii::t('skeeks/form2/app', 'Check the correctness of filling the form fields');
                    }

                } else {
                    $rr->success = false;
                    $rr->message = \Yii::t('skeeks/form2/app', 'Check the correctness of filling the form fields');
                }

                return (array)$rr;
            }
        }
    }
996257
public function actionContact()
	{
		$model=new ContactForm;
		if(isset($_POST['ContactForm']))
		{
			$model->attributes=$_POST['ContactForm'];
			if($model->validate())
			{
				$name='=?UTF-8?B?'.base64_encode($model->name).'?=';
				$subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
				$headers="From: $name <{$model->email}>\r\n".
					"Reply-To: {$model->email}\r\n".
					"MIME-Version: 1.0\r\n".
					"Content-Type: text/plain; charset=UTF-8";

				mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers);
				Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
				$this->refresh();
			}
		}
		$this->render('contact',array('model'=>$model));
	}
412110
public function submitAction(Request $request)
    {
        $name = $request->get('name');

        /** @var RequestConfiguration $configuration */
        $configuration = $this->requestConfigurationFactory->createSimple($request);
        $formConfiguration = $this->configurationFactory->create($name);

        $form = $this->createForm($formConfiguration->getForm());
        $form->handleRequest($request);

        $sent = false;
        if($form->isSubmitted()) {
            if($form->isValid()) {
                $model = $form->getData();
                $this->contactMailer->send($name, $model);
                $form = $this->createForm($formConfiguration->getForm());
                $sent = true;

                if($request->isXmlHttpRequest()) {
                    return new JsonResponse(array(
                        'message' => $this->translator->trans('contact.form.message.success', [], 'EnhavoContactBundle')
                    ));
                }
            } else {
                $errors = $this->formErrorResolver->getErrors($form);
                if($request->isXmlHttpRequest()) {
                    return new JsonResponse(array(
                        'message' => $errors[0]
                    ), 400);
                } else {
                    $this->addFlash('error', $errors);
                }
            }
        }

        $redirectRoute = null;
        if($request->get('_redirect_route')) {
            $redirectRoute = ($request->get('_redirect_route'));
        }

        $redirectParameters = [];
        if($request->get('_redirect_route_parameters')) {
            $redirectParameters = json_decode($request->get('_redirect_route_parameters'));
        }

        if($redirectRoute) {
            return $this->redirectToRoute($redirectRoute, $redirectParameters, 302);
        }

        $template = $configuration->getTemplate($formConfiguration->getPageTemplate());
        return $this->render($template, [
            'form' => $form->createView(),
            'name' => $name,
            'sent' => $sent
        ]);
    }
1037443
public function send()
    {
        $to      = $this->getHeaderLine('to');
        $subject = $this->subject;
        $message = $this->message;

        return mail($to, $subject, $message, $this->parseHeaders());
    }