Views Exposed Formの複数単語入力(textfield)をフォーム上だけ複数行入力(textarea)にする方法

カテゴリ Views Exposed Filter コアバージョン 8.4x 関連モジュール hook_views_pre_view

modles/custom/you_module/you_module.module

/**
 * Views Exposed form.
 *
 * @param $form
 * @param FormStateInterface $form_state
 * @param $form_id
 */
function your_module_form_views_exposed_form_alter(&$form, FormStateInterface $form_id) {
  switch ($form['#id']) {
    case 'your_form_id':
      $form['field_xxxxx']['#type'] = 'textarea';
      $form['field_xxxxx']['#rows'] = 5;
      break;
  }
}
/**
 * Views pre view.
 *
 * @param \Drupal\views\ViewExecutable $view
 * @param $display_id
 * @param array $args
 */
function your_module_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  if ($view->id() == 'your_view_id' && $display_id == 'your_display_id) {
      $value = \Drupal::request()->query->get('field_xxxxx');
      if (!empty($value)) {
        $value = trim(preg_replace('![\r\n]+!', ' ', $value));
        \Drupal::request()->query->set('field_xxxxxx', $value);
      }
    }
  }
}

OTHER FAQ

Drupal開発・運用の疑問/質問の答えはここに

無料ユーザー登録すると質問できます。

カテゴリ昇順で並び替える Core Ver. 関連モジュール タイトル
サイトの環境設定 7.15 トップ(ホーム)ページを変更するには?
サイトの構築 7.38 deployment 冗長構成におけるアップロードおよび時間指定公開について
サイトの構築 8.3x Webform Webformモジュール メールアドレスの入力ミス確認
サイトの構築 7.50 Module Missing Message Fixer モジュールをアンインストールしたらエラーがでるようになった
サイトの構築 7.19 Plesk Pleskでdrupal7(プライベートファイルシステム)を使う場合の注意点
サイトの構築 7.26 Field Views フォーム選択肢(プルダウンやチェックボックス、ラジオボタン)のカスタマイズ方法
サイトの構築 7.38 Content Template ページテンプレートが反映されません。
サイトの構築 7.23 Conditional fields ノード編集フォームを動的にしたい
サイトの構築 8.9.x Webform drupalを使用した登録、一覧表示の方法について
サイトの構築 7.22 Views Devel Viewsの設定ページが変に?
サイトの構築 7.41 Rules Paygent モジュールについて
サイトの構築 7.34 ECK Entityの使い方について
サイトの構築 7.22 Views フィールドセットの伸縮をノンプログラミングでやりたい
サイトの構築 7.59 Drupal.ajax drupal 7 で Uncaught TypeError: Drupal.ajax is undefined となったときの対応方法
サイトの構築 7.31 Views ブロックViewsの絞り込みが表示されない
サイトの構築 7.27 Context block ページ別、カテゴリ別等でブロックの表示有無を簡単にするには
コンテンツの管理 7.15 Views Bulk Operation 標準のコンテンツ編集/ユーザ一覧ページが物足りません
コンテンツの管理 8.5.x Field File コンテンツのフィールドの表示について
コンテンツの管理 7.15 Pagenation 一つの長いページをBookなどのように連続して読ませることはできますか?
コンテンツの管理 8.4x Entity EntityをPropertyで探す(クエリする)方法

ページ