- π·πΈSerbia bojanz
Retitling for clarity. And changing version because new features only go into 2.0.x.
We are talking about the field override UI here. Disabling fields via form_alter already works via #after_build:
public function buildForm(array $form, FormStateInterface $form_state) { $form['address'] = [ '#type' => 'address', '#default_value' => [ 'country_code' => 'US', 'administrative_area' => 'CA', 'locality' => 'Mountain View', 'postal_code' => '94043', 'address_line1' => '1098 Alta Ave', 'organization' => 'Google Inc.', 'given_name' => 'John', 'family_name' => 'Smith', ], '#after_build' => [[get_class($this), 'disableFields']], ]; $form['submit'] = [ '#type' => 'submit', '#value' => $this->t('Submit'), ]; return $form; } /** * #after_build callback: Disables certain fields. */ public static function disableFields(array $element, FormStateInterface $form_state) { $element['address_line2']['#attributes']['disabled'] = 'disabled'; return $element; }
We should add this example to the documentation.