PageSourceSearch

https://kpia.re.kr/assets/controllers/base/form_meta_context_controller-b180af3c.js

js kpia.re.kr collected 2026-10-03 00:24:45 UTC 1,446 bytes, 51 lines download raw bytes

1import { Controller } from '@hotwired/stimulus';
2import { devWarn } from 'helpers/logger';
3
4/**
5 * @domain 폼 라이프사이클
6 * @concern 폼 제출 시 현재 컨트롤러/액션 컨텍스트 첨부
7 * @description meta 태그의 rails-controller/rails-action 값을 읽어 hidden input으로 폼에 추가하는 컨트롤러
8 */
9export default class extends Controller {
10  static values = {
11    controllerParamName: {
12      type: String,
13      default: 'source_controller',
14    },
15    actionParamName: {
16      type: String,
17      default: 'source_action',
18    },
19  };
20
21  submit(event) {
22    const form = event.target;
23
24    const controller = this._getMeta('rails-controller');
25    const action = this._getMeta('rails-action');
26
27    if (!controller || !action) {
28      devWarn('[form-meta-context] rails-controller / rails-action 메타 태그를 찾지 못했습니다.');
29      return;
30    }
31
32    this._ensureHiddenField(form, this.controllerParamNameValue, controller);
33    this._ensureHiddenField(form, this.actionParamNameValue, action);
34  }
35
36  _getMeta(name) {
37    return document.querySelector(`meta[name="${name}"]`)?.content || '';
38  }
39
40  _ensureHiddenField(form, name, value) {
41    let input = form.querySelector(`input[name="${name}"]`);
42    if (!input) {
43      input = Object.assign(document.createElement('input'), {
44        type: 'hidden',
45        name,
46      });
47      form.append(input);
48    }
49    input.value = value;
50  }
51}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.