You are here

function ahah_example_simplest in Examples for Developers 6

This trivial form builder function just creates a box as a section on the page which can be replaced when AHAH-enabled submit element fires.

1 string reference to 'ahah_example_simplest'
ahah_example_menu in ahah_example/ahah_example.module
Implement hook_menu().

File

ahah_example/ahah_example_simplest_ahah.inc, line 12
A Hello-world AHAH. Just swaps out a markup section on submit.

Code

function ahah_example_simplest(&$form_state) {
  $form['explanation'] = array(
    '#type' => 'markup',
    '#value' => '<div>' . t('This is the very simplest AHAH example, which just replaces the HTML for a div on the page. Notice the more advanced examples in the other tabs.') . '</div>',
  );
  $initial_markup = '<div style="width: 150px; height: 150px; border: 1px solid black">' . t('This box will be replaced') . '</div>';
  $form['box'] = array(
    '#type' => 'markup',
    '#prefix' => '<div id="box">',
    '#suffix' => '</div>',
    '#value' => $initial_markup,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#ahah' => array(
      'path' => 'examples/ahah_example/simplest_ahah/callback',
      'wrapper' => 'box',
    ),
    '#value' => t('Click Me to change box color'),
  );
  return $form;
}