public function FacebookPostBlock::blockForm in Social Feed 8
Returns the configuration form elements specific to this block plugin.
Blocks that need to add form elements to the normal block configuration form should implement this method.
Parameters
array $form: The form definition array for the block configuration form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The renderable form array representing the entire configuration form.
Overrides SocialBlockBase::blockForm
File
- src/
Plugin/ Block/ FacebookPostBlock.php, line 81
Class
- FacebookPostBlock
- Provides a 'FacebookPostBlock' block.
Namespace
Drupal\socialfeed\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$form = parent::blockForm($form, $form_state);
$post_type_options = [
'permalink_url',
'status',
'photo',
'video',
];
$form['overrides']['page_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Facebook Page Name'),
'#default_value' => $this
->defaultSettingValue('page_name'),
'#description' => $this
->t('eg. If your Facebook page URL is this @facebook, then use YOUR_PAGE_NAME above.', [
'@facebook' => 'http://www.facebook.com/YOUR_PAGE_NAME',
]),
'#size' => 60,
'#maxlength' => 100,
'#required' => TRUE,
];
$form['overrides']['app_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Facebook App ID'),
'#default_value' => $this
->defaultSettingValue('app_id'),
'#size' => 60,
'#maxlength' => 100,
'#required' => TRUE,
];
$form['overrides']['secret_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('Facebook Secret Key'),
'#default_value' => $this
->defaultSettingValue('secret_key'),
'#size' => 60,
'#maxlength' => 100,
'#required' => TRUE,
];
$form['overrides']['user_token'] = [
'#type' => 'textfield',
'#title' => $this
->t('Facebook User Token'),
'#default_value' => $this
->defaultSettingValue('user_token'),
'#description' => $this
->t('This is available at @facebook', [
'@facebook' => 'https://developers.facebook.com/tools/explorer/',
]),
'#size' => 60,
'#maxlength' => 255,
'#required' => TRUE,
];
$form['overrides']['user_token'] = [
'#type' => 'textfield',
'#title' => $this
->t('Facebook User Token'),
'#default_value' => $this
->defaultSettingValue('user_token'),
'#size' => 60,
'#maxlength' => 255,
'#required' => TRUE,
];
$form['overrides']['no_feeds'] = [
'#type' => 'number',
'#title' => $this
->t('Number of Feeds'),
'#default_value' => $this
->defaultSettingValue('no_feeds'),
'#size' => 60,
'#maxlength' => 60,
'#max' => 100,
'#min' => 1,
];
$form['overrides']['all_types'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show all post types'),
'#default_value' => $this
->defaultSettingValue('all_types'),
'#states' => [
'required' => [],
],
];
$form['overrides']['post_type'] = [
'#type' => 'select',
'#title' => 'Select your post type(s) to show',
'#default_value' => $this
->defaultSettingValue('post_type'),
'#options' => array_combine($post_type_options, $post_type_options),
'#empty_option' => $this
->t('- Select -'),
'#states' => [
'visible' => [
':input[name="settings[overrides][all_types]"]' => [
'checked' => FALSE,
],
],
'required' => [
':input[name="settings[overrides][all_types]"]' => [
'checked' => FALSE,
],
],
],
];
$this
->blockFormElementStates($form);
return $form;
}