protected function BreakpointFormTrait::addBreakpointsForm in Doubleclick for Publishers (DFP) 8
Helper form builder for the breakpoints form.
1 call to BreakpointFormTrait::addBreakpointsForm()
File
- src/
Form/ BreakpointFormTrait.php, line 95 - Contains \Drupal\dfp\Form\BreakpointFormTrait.
Class
- BreakpointFormTrait
- Provides form for adding breakpoints to a DFP tag.
Namespace
Drupal\dfp\FormCode
protected function addBreakpointsForm(array &$breakpoints_form, array $existing_breakpoints = []) {
// Display settings.
$breakpoints_form['breakpoints'] = [
'#type' => 'markup',
'#tree' => FALSE,
'#prefix' => '<div id="dfp-breakpoints-wrapper">',
'#suffix' => '</div>',
'#element_validate' => [
[
get_class($this),
'breakpointsFormValidate',
],
],
];
$breakpoints_form['breakpoints']['table'] = [
'#type' => 'table',
'#header' => [
$this
->t('Browser Size'),
$this
->t('Ad Size(s)'),
],
];
$breakpoints_form['breakpoints']['help'] = [
'#type' => 'markup',
'#prefix' => '<p>',
'#markup' => $this
->t('These breakpoints are set to implement DFP responsive mappings. See <a href="https://support.google.com/dfp_premium/answer/3423562?hl=en">this support article</a> for more information.'),
'#suffix' => '</p>',
];
// Add existing breakpoints to the form unless they are empty.
foreach ($existing_breakpoints as $key => $data) {
$this
->addBreakpointForm($breakpoints_form, $key, $data);
}
// Add one blank set of breakpoint fields.
$this
->addBreakpointForm($breakpoints_form, count($existing_breakpoints));
$breakpoints_form['breakpoints']['dfp_more_breakpoints'] = [
'#type' => 'submit',
'#value' => $this
->t('Add another breakpoint'),
'#submit' => [
[
get_class($this),
'moreBreakpointsSubmit',
],
],
'#limit_validation_errors' => [],
'#ajax' => [
'callback' => [
get_class($this),
'moreBreakpointsJs',
],
'wrapper' => 'dfp-breakpoints-wrapper',
'effect' => 'fade',
],
];
}