public function AttributeEditForm::buildForm in Ubercart 8.4
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides AttributeFormBase::buildForm
File
- uc_attribute/
src/ Form/ AttributeEditForm.php, line 15
Class
- AttributeEditForm
- Defines the attribute edit form.
Namespace
Drupal\uc_attribute\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $aid = NULL) {
$attribute = uc_attribute_load($aid);
$form = parent::buildForm($form, $form_state);
$form['#title'] = $this
->t('Edit attribute: %name', [
'%name' => $attribute->name,
]);
$form['aid'] = [
'#type' => 'value',
'#value' => $attribute->aid,
];
$form['name']['#default_value'] = $attribute->name;
$form['label']['#default_value'] = $attribute->label ?: $attribute->name;
$form['description']['#default_value'] = $attribute->description;
$form['required']['#default_value'] = $attribute->required;
$form['display']['#default_value'] = $attribute->display;
$form['ordering']['#default_value'] = $attribute->ordering;
return $form;
}