1 link_field_custom_form_test.module link_field_custom_form_test_form(array $form, array &$form_state)

Custom form for testing link field.

Parameters

array $form: The form array.

array $form_state: The form state array.

See also

link_field_custom_form_test_menu()

File

core/modules/link/tests/modules/link_field_custom_form_test/link_field_custom_form_test.module, line 33
Helper module for testing link fields with custom forms.

Code

function link_field_custom_form_test_form(array $form, array &$form_state) {
  $form = array();
  $form['link_test_defaults'] = array(
    '#type' => 'link_field',
    '#title' => t('Link defaults'),
    '#required' => TRUE,
  );
  $form['link_test_title_changes'] = array(
    '#type' => 'link_field',
    '#title' => t('Link with title changed'),
    '#link_field_options' => array(
      'title_maxlength' => 16,
      'title_label_use_field_label' => TRUE,
    ),
  );
  $form['link_test_internal_no_title'] = array(
    '#type' => 'link_field',
    '#title' => t('Link without title'),
    '#link_field_options' => array(
      'title_mode' => 'none',
      'link_type' => 'internal',
    ),
  );
  $form['link_test_validate_url'] = array(
    '#type' => 'link_field',
    '#title' => t('Required link with URL validation'),
    '#required' => TRUE,
    '#link_field_options' => array(
      'url_mode' => 'required',
      'title_mode' => 'required',
      'validate_url' => TRUE,
    ),
    '#default_value' => array(
      'title' => 'Example title on custom link field',
      'url' => 'http://example.com',
    ),
  );
  $form['configurable_title_and_class'] = array(
    '#type' => 'link_field',
    '#title' => t('Link with configurable title and class'),
    '#link_field_options' => array(
      'configurable_title' => TRUE,
      'configurable_class' => TRUE,
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}