New answers tagged forms
1
vote
When a custom form is displayed in a custom template, ajax does not work
The only variable available in a #theme form template is
{{ form }}
and this is the only thing you need to render. If you render single form elements or groups then include the rest of the form ...
- 93.7k
0
votes
Accepted
Form field states with media fields that use media library widget and conditionally displaying visibility based on other media fields
This is probably not the way to address media fields states, however it is a solution (or work around I was able to come up with).
Using hook_form_alter() the same hook I'm using to work with the ...
- 23
0
votes
Block Configuration Form Returning Unexpected Value
The fix suggested by @unusedspoon took care of the radio element value problem. The form element value was properly set after removing the 'name' => 'field_log_file_format' attribute from the '...
0
votes
Accepted
Storing temporary data in a form AJAX callback
Data can be stored in the form submission using $form_state->set('[ARBITRARY KEY]', $value), then retrieved when the form is rebuilt with $value = $form_state->get('[ARBITRARY KEY]'). On the ...
- 16.4k
1
vote
Accepted
Check in buildForm method of custom form class if the form was submitted
The form is submitted when there is user input:
public function buildForm(array $form, FormStateInterface $form_state) {
if ($form_state->getUserInput()) {
// The form was submitted.
// ...
- 93.7k
0
votes
How to remove author field from the 'advanced' field group on the node edit form
This works... though it doesn't look quite right to me.
function MYTHEME_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$form['author']=['#group'...
- 193
Top 50 recent answers are included
Related Tags
forms × 67687 × 2096
8 × 1393
ajax × 997
theming × 536
users × 402
nodes × 393
webforms × 302
javascript × 282
hooks × 282
views × 239
entities × 228
files × 206
6 × 194
blocks × 141
9 × 122
commerce × 116
emails × 95
routes × 90
taxonomy-terms × 89
database × 89
redirection × 89
media × 88
comments × 73
datetime × 69