Provide form widget type

Created on 29 December 2017, almost 7 years ago
Updated 19 June 2024, 5 months ago

As seen in the AceFormatter, rendering an ACE widget is cumbersome:

      $elements[$delta] = array(
        '#type' => 'textarea',
        '#value' => $item->value,
        // Attach libraries as per the setting.
        '#attached' => array(
          'library' => array(
            'ace_editor/formatter',
            'ace_editor/theme.' . $settings['theme'],
            'ace_editor/mode.' . $settings['syntax'],
          ),
          'drupalSettings' => array(
             // Pass settings variable ace_formatter to javascript.
            'ace_formatter' => $settings,
          ),
        ),
        '#attributes' => array(
          "class" => array("content"),
          "readonly" => "readonly",
        ),
        '#prefix' => "<div class='ace_formatter'>",
        '#suffix' => "<div>",

      );

Let's provide a render element that makes it like this:

      $elements[$delta] = array(
        '#type' => 'ace_textarea',
        '#syntax' => 'css',
        // Optionally some other ace options...
        '#default_value' => $item->value,
      );
📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇩🇪Germany geek-merlin Freiburg, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024