protected function SharerichForm::buildOverviewFormRows in Sharerich 8
Helper to build rows of services.
Return value
$form array. The form containing services.
1 call to SharerichForm::buildOverviewFormRows()
- SharerichForm::buildOverviewForm in src/
Form/ SharerichForm.php - Helper to build list of services.
File
- src/
Form/ SharerichForm.php, line 129 - Contains \Drupal\sharerich\Form\SharerichForm.
Class
- SharerichForm
- Class SharerichForm.
Namespace
Drupal\sharerich\FormCode
protected function buildOverviewFormRows() {
$storage = $this->entity
->getServices();
$weight = 0;
foreach (sharerich_get_default_services() as $name) {
$form[$name]['#attributes']['class'][] = 'draggable';
$form[$name]['title'] = array(
'#markup' => isset($storage[$name]['label']) ? $storage[$name]['label'] : ucfirst($name),
);
$form[$name]['enabled'] = array(
'#type' => 'checkbox',
'#title' => '',
'#title_display' => 'invisible',
'#default_value' => isset($storage[$name]['enabled']) ? $storage[$name]['enabled'] : FALSE,
);
$form[$name]['weight'] = array(
'#type' => 'textfield',
'#title' => '',
'#title_display' => 'invisible',
'#default_value' => isset($storage[$name]['weight']) ? $storage[$name]['weight'] : $weight++,
'#attributes' => array(
'class' => array(
'item-weight',
),
),
'#size' => 3,
);
$form[$name]['#weight'] = $form[$name]['weight']['#default_value'];
$form[$name]['markup'] = array(
'#type' => 'textarea',
'#default_value' => isset($storage[$name]['markup']) ? $storage[$name]['markup'] : sharerich_load_default_service($name),
'#states' => array(
'invisible' => array(
':input[name="services[' . $name . '][enabled]"]' => array(
'checked' => FALSE,
),
),
),
'#attributes' => array(
'class' => array(
'markup',
),
),
'#suffix' => '<a class="button reset">' . $this
->t('Reset') . '</a>',
);
$form[$name]['default_markup'] = array(
'#type' => 'hidden',
'#default_value' => sharerich_load_default_service($name),
'#attributes' => array(
'class' => array(
'default-markup',
),
),
);
$form[$name]['id'] = array(
'#type' => 'hidden',
'#value' => $name,
);
}
uasort($form, array(
'Drupal\\Component\\Utility\\SortArray',
'sortByWeightProperty',
));
return $form;
}