How can I set value to hidden field (Form Api) and send them with post method?
To summarize the question : I use an API where a SHA signature had to be sent along the form . That signature is calculated based on the other form inputs, so it had to be calculated after the user clicks the submit button and it had to be sent as a form field with POST method .

In buildForm(), I have :

$form['#action'] = 'https://url-webservices.fr/';


It is like it is executed before I can call validateForm() where I can set the value I need.

I've searched a lot for a solution but didn't find an easy way like set a news value in submitForm(). 

So here is a solution. I'm not completely happy with it but it works.

I've built a 2 steps forms.

In first step, the $form['#action'] is empty. After validation, I set a value to $form['#action'] and to the form fields I need :

$form_state-&gt;setValue('action', $url_action);


I also change the text of the submit button with something like "confirm".

Then user could confirm and validate the form.

All the mechanic of the 2 steps could be seen in that answer (thanx to Clive) :

How to use ConfirmFormBase to confirm the action of another form?