You are here

README.txt in Select (or other) 4.x

Same filename and directory in other branches
  1. 8 README.txt
  2. 6.2 README.txt
  3. 6 README.txt
  4. 7.3 README.txt
  5. 7.2 README.txt
CONTENTS OF THIS FILE
---------------------

 * Introduction
 * Installation
 * Applications
 * Usage example
   - Field widget
   - Forms API element
 * Maintainers


INTRODUCTION
------------

Provides a new Forms API element which is a select/radios/checkboxes element
that has an 'other' option. When 'other' is selected a textfield appears for
the user to provide a custom value.

 * For a full description of the module, visit the project page:
   https://www.drupal.org/project/select_or_other

 * To submit bug reports and feature suggestions, or to track changes:
   https://www.drupal.org/project/issues/select_or_other


INSTALLATION
------------
 * Install as you would normally install a contributed Drupal module. Visit:
   https://drupal.org/documentation/install/modules-themes/modules-8
   for further information.


APPLICATIONS
------------
 * As a Field widget for (auto create) Entity reference fields.

 * As a Forms API element for developers. Therefor can be integrated into any
   form or module.


USAGE EXAMPLE
-------------
Field widget
============
This is an example to use the Field widget. First make sure you have a Taxonomy
vocabulary.

1. Go to Structure and add a new Content type.

2. Add a field with field type Taxonomy term.

3. Edit this field and select "Create referenced entities if they don't already
   exist" and save.

4. Go to Manage form display and select "Select or Other" in the Widget column.

You can find the "Other" option by adding new content.


Forms API element
=================
For the developers, this example is about the Forms API element. Start with
the custom module tutorial at:
https://www.drupal.org/docs/8/creating-custom-modules/add-a-form-to-the-block-configuration

Then go to /hello_world/src/Plugin/Block/HelloBlock.php and place the following
before "return $form;":

    $form['hello_block_settings'] = array(
        '#type' => 'select_or_other_select',
        '#title' => t('Options'),
        '#options' => array(
            'value_1' => t('One'),
            'value_2' => t('Two'),
        ),
        '#multiple' => TRUE,
        '#other_unknown_defaults' => 'other',
        '#other_delimiter' => ', ',
    );

The menu should now appear in the block settings. For more information visit:
https://www.drupal.org/node/1158654



MAINTAINERS
-----------
Maintainer: Chris Jansen (https://www.drupal.org/u/legolasbo)

File

README.txt
View source
  1. CONTENTS OF THIS FILE
  2. ---------------------
  3. * Introduction
  4. * Installation
  5. * Applications
  6. * Usage example
  7. - Field widget
  8. - Forms API element
  9. * Maintainers
  10. INTRODUCTION
  11. ------------
  12. Provides a new Forms API element which is a select/radios/checkboxes element
  13. that has an 'other' option. When 'other' is selected a textfield appears for
  14. the user to provide a custom value.
  15. * For a full description of the module, visit the project page:
  16. https://www.drupal.org/project/select_or_other
  17. * To submit bug reports and feature suggestions, or to track changes:
  18. https://www.drupal.org/project/issues/select_or_other
  19. INSTALLATION
  20. ------------
  21. * Install as you would normally install a contributed Drupal module. Visit:
  22. https://drupal.org/documentation/install/modules-themes/modules-8
  23. for further information.
  24. APPLICATIONS
  25. ------------
  26. * As a Field widget for (auto create) Entity reference fields.
  27. * As a Forms API element for developers. Therefor can be integrated into any
  28. form or module.
  29. USAGE EXAMPLE
  30. -------------
  31. Field widget
  32. ============
  33. This is an example to use the Field widget. First make sure you have a Taxonomy
  34. vocabulary.
  35. 1. Go to Structure and add a new Content type.
  36. 2. Add a field with field type Taxonomy term.
  37. 3. Edit this field and select "Create referenced entities if they don't already
  38. exist" and save.
  39. 4. Go to Manage form display and select "Select or Other" in the Widget column.
  40. You can find the "Other" option by adding new content.
  41. Forms API element
  42. =================
  43. For the developers, this example is about the Forms API element. Start with
  44. the custom module tutorial at:
  45. https://www.drupal.org/docs/8/creating-custom-modules/add-a-form-to-the-block-configuration
  46. Then go to /hello_world/src/Plugin/Block/HelloBlock.php and place the following
  47. before "return $form;":
  48. $form['hello_block_settings'] = array(
  49. '#type' => 'select_or_other_select',
  50. '#title' => t('Options'),
  51. '#options' => array(
  52. 'value_1' => t('One'),
  53. 'value_2' => t('Two'),
  54. ),
  55. '#multiple' => TRUE,
  56. '#other_unknown_defaults' => 'other',
  57. '#other_delimiter' => ', ',
  58. );
  59. The menu should now appear in the block settings. For more information visit:
  60. https://www.drupal.org/node/1158654
  61. MAINTAINERS
  62. -----------
  63. Maintainer: Chris Jansen (https://www.drupal.org/u/legolasbo)