1 block_example.inc | BlockExample::form(&$form, &$form_state) |
Builds the block's configuration form.
The values of the form elements defined here will be merged with defaults from the parent class (Block class in this case) and made available in the formValidate() and formSubmit() functions.
Block class adds default form elements to allow users to change the block's title. If you do not wish for users to be able to define custom block titles, you can set access to the title elements to false, and then define a custom title element, as in the following example:
$form['title_display']['title_display']['#access'] = FALSE; $form['title_display']['title'] = array( '#type' => 'textfield', '#title' => t('Display title'), '#default_value' => $this->settings['title'], );
You would then need to explicitly save a value for 'title' in formSubmit().
Overrides Block::form
File
- modules/
examples/ block_example/ block_example.inc, line 63
Class
- BlockExample
- BlockExample extends Block
Code
function form(&$form, &$form_state) {
parent::form($form, $form_state);
$form['content'] = array(
'#type' => 'text_format',
'#title' => t('Block content'),
'#default_value' => !empty($this->settings['content']) ? $this->settings['content'] : '',
'#format' => !empty($this->settings['format']) ? $this->settings['format'] : 'filtered_html',
'#editor_uploads' => TRUE,
'#rows' => 5,
);
}