Ad

Retrieving An Input Value October Cms

I wanna retrieve input value from 'term' field. ( 'term' is a $belongsTo relationship so retrieved value should be an integer like 1,2,3.. )

I tried this code but didn't work. What am i missing?

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

YAML file

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

My model (Event)

i'm trying fill dropdown option with a function like below in model.

  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' ];
            } 
        }
Ad

Answer

This are working. Notice all are lower case -

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

note: you may need your controller name. For example

post('YurController[field_name]')

Also also you can use when you have a object

 $model->your_field

So chose one based on your scenario.

Ad
source: stackoverflow.com
Ad