检索输入值 october cms

Retrieving an input value october cms

我想从 'term' 字段中检索输入值。 ('term' 是一个 $belongsTo 关系,所以检索到的值应该是一个整数,如 1,2,3..)

我试过这段代码但没有用。我错过了什么?

$termid = Input::get('term_id');

YAML 文件

fields:
event_name:
    label: 'Event Name'
    span: auto
    required: 1
    type: text
event_description:
    label: 'Event Description'
    size: ''
    span: full
    required: 1
    type: textarea
event_status:
    label: 'Event Status'
    options:
        1: Active
        2: Cancel
        3: 'On Hold'
    span: auto
    type: dropdown
term:
    label: Term
    nameFrom: name
    descriptionFrom: description
    span: auto
    containerAttributes: {  }
    type: relation
    emptyOption: Select
sdate:
    label: Date
    span: auto
    disabled: 0
    hidden: 0
    dependsOn:
        - term
    type: dropdown

我的模型(事件)

我正在尝试使用如下模型中的函数填充下拉选项。

  public function getSdateOptions () {

            // $attributes = $this->getAttributes();
            // $termid = $attributes['term_id'];

            $termid = Input::get('term_id');

        if ($this->term_id == $termid ) {
            $term = Db::table('cng_tennis_term')->where('id', $termid )->first();
            return [  $term->start_date =>  $term->finish_date ]; 
        }
        else {
            return ['Select a date' => 'Select a date' ];
            } 
        }

这是有效的。注意都是小写 -

input(field_name), post('field_name'), get('field_name')

注意:您可能需要您的控制器名称。例如

post('YurController[field_name]')

你也可以在有对象的时候使用

 $model->your_field

所以根据你的场景选择一个。