How do you get and submit a webform in React?

I am planning to build a Drupal 8 site fully decoupled using Gatsby (a site generator for React). So I will use Drupal only to structure (content types, paragraphs), enter and update all the content and data and use React for the frontend.

The website also needs a (simple) form. I want to use the webform module for this.

But how do you get a Drupal form in React and after submitting send all completed fields to the database?

Supporting documents to convince “can not submit original invitation/accommodation”

I am an Indian citizen applying for UK standard visitor visa.

In supporting documents guide for visitor visa, it is mentioned that, All documents must be originals and not photocopies (I am attaching the screenshot).

enter image description here

I am going for a conference in UK, I have got invitation letter and accommodation letter in email as a scanned copy. It will take at least 10 days to get original shipped from UK to my place, assuming the organisers are kind enough to send original immediately.

What supporting documents should I attach to convince the Visa officer to say that I can not submit originals for invitation letter and accommodation?

Submit ur music to BDS n Mediabase n 1000s Radio Stations for $125

Every genre is acceptedbut the song should be registered in the main artist name as well as clean from explicit lyrics. For 125$ only, your track will be submitted (delivery without guarantees) to a huge number of BDS radio stations which spins are calculated for Billboard Charts, and to our Mediabase radios list, and to thousands of other top radio stations and we will give you their names in the delivery. We have also the option of guaranteeing plays and charting of your track on Billboard, USA National Radio Charting, Mediabase, European Indie Top 200 Chart, ITunes, and other Digital Stores Charts! You just have to contact us previously for details…

by: fcgi
Created: —
Category: Audio & Music
Viewed: 11

How reset $form_state on ajax call for get real value in submit?

I have see some post about that,but i still have no real answer.

In my form, user can select a register address in a select field. When he select an address, the ajax set value on some other fields :

enter image description here

The code :

  if($  form_state->getTriggeringElement()['#name']=="mes_adresses")   {       $  listAdresse = $  this->adresse_service->getUserAdresseById($  form_state->getValue('mes_adresses'));    }     $  form['containerGeneral']['livraison']['adresseComplete']['nom_livraison'] = array(       '#title' => 'Nom de livraison',       '#type' => 'textfield',       '#value' => $  listAdresse['nom'],   );    $  form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison'] = array(       '#title' => 'Prénom de livraison',       '#type' => 'textfield',       '#value' => $  listAdresse['prenom'],   );      $  form['containerGeneral']['livraison']['adresseComplete']['pays_livraison'] = array(       '#title' => 'Pays de livraison',       '#type' => 'select',       '#required'=>true,       '#options'=>$  this->taxonomy_service->getTermsByVid('pays_livraison'),             '#value' => $  listAdresse['pays'],   );    $  form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison'] = array(       '#title' => 'Adresse de livraison',       '#type' => 'textfield',       '#value' =>  $  listAdresse['adresse'],   );    $  form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison'] = array(       '#title' => 'Adresse de livraison',       '#type' => 'textfield',       '#value' =>$  listAdresse['adresse2'],   );    $  form['containerGeneral']['livraison']['adresseComplete']['cp_livraison'] = array(       '#title' => 'Code postal de livraison',       '#maxlength'=>5,       '#type' => 'textfield',       '#value' => $  listAdresse['code_postal'],   );    $  form['containerGeneral']['livraison']['adresseComplete']['ville_livraison'] = array(       '#title' => 'Ville de livraison',       '#type' => 'textfield',       '#value' =>$  listAdresse['ville'],   ); 

And the callback :

public function ajaxChangeAdresseCallback(array &$  form, FormStateInterface $  form_state) {      $  form_state->setRebuild(TRUE);     return  $  form['containerGeneral']['livraison']['adresseComplete'];  } 

So there are 2 things :


If you set value like that, user can never change the value because

$  form_state->getValue() 

ll keep the value set by the ajax.


If you set the value like that, that doesn’t work because the #default_value parameter if use just the first time the form is loaded.

The main problem is with $ form_state.

If you kint when you submit your form $ form_state->getValue() and $ _POST, $ _POST is good but not the $ form_state.

But the issue are in the validate function too, if user select the option new address, ajax reload the form, set empty everywhere, and when you submit, the validate function ll tell you you have empty value.

I know on D7 some people unset the $ form_state[‘values];

But on D8 ?

So how reset the $ form_state value ?

Problema de submit no form junto com a API do PagSeuro

Bom, estou com um problema, na parte de progamação, com o jquery eu consegui fazer funcionar tudo(aparecer o cartão, numero de parcelas, hash.. etc) só q n estou conseguindo fazer submit no form, ele não me redireciona para a pagina que eu quero(que é a controller/controllerPedido.php) para poder fazer o checkout , o config.php está correto.

meu checkout.js e meu index.html:

var Root="http://" + document.location.hostname +"/pgseguro/"; var valor = 500.00;    // inicia a sessao com o hash gerado no controllerId.php via json function iniciarSessao() { 	$  .ajax({ 		url: Root+"controller/controllerId.php", 		type: 'POST', 		dataType: 'json', 		success: function(data) { 			PagSeguroDirectPayment.setSessionId(; 		}, 		complete: function() { 			listaMeioPagamento(); 		} 	}); }   //lista o pagamento possiveis com o Pagseguro function listaMeioPagamento() { 	PagSeguroDirectPayment.getPaymentMethods({ 	amount: valor, 	success: function(data) {  		$  .each(data.paymentMethods.CREDIT_CARD.options, function(i, obj){ 			$  ('.cartaoCredito').append("<div><img src="+obj.images.SMALL.path+">"+" </div>"); 		}) 	},  	complete: function(data) { 			getTokenCard(); 		} 	}); } /* Ao digitar o numero do cartao nos 6 primeiros digitos ele usa a função do pagseguro para verificar a bandeira do cartão */ $  ('#numCartao').on('keyup', function() { 	var NumeroCartao = $  (this).val(); // numero do cartao 	var qntCaracteres = NumeroCartao.length; // a qnt de caracters do cartao  	/* quando ver que o num de caracteres for 6 ele faz a verificação( 6 digitos é o minimo) 	para saber a bandeira. 	*/ 	if(qntCaracteres >= 6) { 	PagSeguroDirectPayment.getBrand({ 		cardBin: NumeroCartao, 		success: function(response) { 	  		var bandeiraImg =; // tras o nome da bandeira 	 		 $  ('.bandeiraCartao').html("<img src=" + bandeiraImg + ".png>"); // é gerado um img com o nome da bandeira 	 		 getParcelas(bandeiraImg); 			},  			//caso dê erro é limpado a div do bandeira cartão(caso tenha algo dentro), e é mandado uma msg de erro para o usuario. 		error: function(response) { 			$  ('.bandeiraCartao').empty(); 			$  ('.msgError').html("<span>Cartão invalido!</span>") 		}, 	}); } });   // exibe a quantidade e valores das parcelas  function getParcelas(bandeira) { PagSeguroDirectPayment.getInstallments({         amount: valor, // traz o valor do pruduto         maxInstallmentNoInterest: 2, // o numero de parcelas q não será cobrado juros         brand: bandeira, // a bandeira vinda por parametro          success: function(response){         	/*o primeiro foreach lê o json enviado no parametro response que são varios arrays,          	 o segundo foreach($  .each) abaixo remove todos os valores dentro da tag <select> 			isso evita a duplicação nas parcelas, sempre que for mostrado as parcelas  			é retirado tudo que esta dentro.         	 */          $  .each(response.installments,function(i,obj){                 $  .each(obj,function(i2,obj2){                     var numberValue = obj2.installmentAmount;                     var num = "R$   "+ numberValue.toFixed(2).replace(".",",");                     var numParcelas = numberValue.toFixed(2);                     $  ('#qtdParcelas').show().append("<option value='" + obj2.quantity + "' title='" + numParcelas + "'>"+obj2.quantity+" parcelas de " + num + "</option>");                 });             });        	          }, // fim do succsess 	}); }  $  ("#qtdParcelas").on('change', function() { 	var valueSelected = document.getElementById('qtdParcelas'); 	$  ('#valorParcelas').val(valueSelected.options[valueSelected.selectedIndex].title); });  //pega o token do Cartão function getTokenCard() { 	PagSeguroDirectPayment.createCardToken({    cardNumber: '4111111111111111', // Número do cartão de crédito    brand: 'visa', // Bandeira do cartão    cvv: '123', // CVV do cartão    expirationMonth: '12', // Mês da expiração do cartão    expirationYear: '2030', // Ano da expiração do cartão, é necessário os 4 dígitos.    success: function(response) {         $  ('#tokenCard').val(response.card.token);    },  }); }  // Gera o hash do cartão $  ('#btnComprar').on('click', function(event) { 	event.preventDefault(); 	PagSeguroDirectPayment.onSenderHashReady(function(response){ 		$  ("#hashCard").val(response.senderHash); 	}); })  iniciarSessao();
<!DOCTYPE html> <html lang="pt-br"> <head> 	<meta charset="UTF-8"> 	<title>Document</title> 	<link rel="stylesheet" href="libraries/style.css"> </head> <body> 	  	<form name="form1" method="post" action="controller/controllerPedido.php"> 		<input type="text" id="numCartao" name="numCartao"> 		<input type="text" id="tokenCard"> 		<input type="text" id="hashCard" name="hashCard"> 		<div class="bandeiraCartao"></div> 		<div class="msgError"></div> 		<select name="qtdParcelas" id="qtdParcelas"> 			<option value="">Selecione</option> 		</select> 		<input type="text" id="valorParcelas" name="valorParcelas">  		<input type="submit" id="btnComprar" name="btnComprar"> 	</form>    	<div class="cartaoCredito"></div> 	<div class="boleto"></div> 	<div class="debito"></div> 	   	<script type="text/javascript" src= ""></script> 	<script src="libraries/zepto.min.js"></script> 	<script src="libraries/checkout.js"></script> </body> </html>

<?php  include("../config/config.php")  $  tokenCard = $  _POST["tokenCard"]; $  hashCard = $  _POST["hashCard"]; $  qtdParcelas = filter_input(INPUT_POST,'qtdParcelas',FILTER_SANITIZE_SPECIAL_CHARS); $  valorParcelas = filter_input(INPUT_POST,'valorParcelas',FILTER_SANITIZE_SPECIAL_CHARS); $  data["email"] = EMAIL_PAGSEGURO; $  data["token"] = TOKEN_SANDBOX; $  data["currency"]="BRL"; $  data["paymentMode"] = "default"; $  data["paymentMethod"] = "creditCard"; $  data["receiverEmail"] = EMAIL_PAGSEGURO; $  data["notificationURL"] = ""; // aqui pode ser feito um loop caso exista mais de um item na compra // todos obrigatorios $  data["itemId1"]="1"; $  data["itemDescription1"]="Notebook Prata"; $  data["itemAmount1"]="500.00"; // valor do item $  data["itemQuantity1"]="1"; $  data["itemWeight1"]="1000"; ///////////////// $  data["reference"]="83783783737"; $  data["senderName"]="João da Silva"; // nome do comprador e os dados dele abaixo $  data["senderCPF"] = "11111111111"; $  data["senderAreaCode"]="37"; $  data["senderPhone"]="99999999"; $  data["senderEmail"]=""; $  data["senderHash"] = $  hashCard; $  data["shippingAddressRequire"] = true; $  data["creditCardToken"] = $  tokenCard; $  data["installmentQuantity"] = $  qtdParcelas; $  data["installmentValue"] = $  qtdParcelas; $  data["noInterestInstallmentQuantity"] = 2; $  data["creditCardHolderName"]='Jose Comprador'; $  data["creditCardHolderCPF"]='22111944785'; $  data["creditCardHolderBirthDate"]='27/10/1987'; $  data["creditCardHolderAreaCode"]='37'; $  data["creditCardHolderPhone"]='99999999'; $  data["billingAddressStreet"]='Av. Brig. Faria Lima'; $  data["billingAddressNumber"]='1384'; $  data["billingAddressComplement"]='5 Andar'; $  data["billingAddressDistrict"]='Jardim Paulistano'; $  data["billingAddressPostalCode"]='01452002'; $  data["billingAddressCity"]='Sao Paulo'; $  data["billingAddressState"]='SP'; $  data["billingAddressCountry"]="BRA";   $  buildQuery=http_build_query($  data); $  url = "";  $  curl = curl_init($  url); curl_setopt($  curl,CURLOPT_HTTPHEADER,Array("Content-Type: application/x-www-form-urlencoded; charset=UTF-8")); curl_setopt($  curl,CURLOPT_POST,true); curl_setopt($  curl,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($  curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($  curl,CURLOPT_POSTFIELDS,$  buildQuery); $  return = curl_exec($  curl); curl_close($  curl);  $  xml = simplexml_load_string($  return); echo $  xml->code;