title: OctoberCMS Builder Plugin backend dropdown
body: <p>I would like to create a plugin where to create <code>Posts</code>, each post belong to 1 <code>Category</code>.</p>
  
  <p>And there is a dropdown menu at the backend where you can choose which category the post belongs to when you are creating a post. </p>
  
  <p>However, I want the the options in such dropdown depend on the model <code>Category</code> where the <code>Value</code> is <code>category.name</code> and <code>Key</code> is <code>category.id</code> instead of me typing the string into it.</p>
  
  <p>Please help! Thanks</p>
  
  <h2>Thanks to Dragontree's suggestions: here is my 1st EDIT:</h2>
  
  <p>I already have my relationship set as followings:</p>
  
  <p>in <code>/models/Category.php</code></p>
  
  <pre><code>public $hasMany = [
      'posts' =&gt; ['stephenli\plugin\Models\Posts']
  ];
  </code></pre>
  
  <p>in <code>/models/Post.php</code></p>
  
  <pre><code>public $belongsTo = [
      'category' =&gt; ['stephenli\plugin\Models\Category', 'key' =&gt; 'category_id']
  ];       /* I tried with or without  'key' =&gt; 'category_id'*/
  </code></pre>
  
  <p>and used relation widget at the <code>Builder</code> Plugin, </p>
  
  <p>in <code>/models/post/field.yaml</code></p>
  
  <pre><code>category_id:
      label: 'stephenli.postgod::lang.plugin.categorypick_label'
      oc.commentPosition: ''
      nameFrom: name
      descriptionFrom: description
      emptyOption: 'No categories found'
      span: auto
      type: relation
  </code></pre>
  
  <p>where in <code>/models/post/columns.yaml</code></p>
  
  <pre><code>category_id:
      label: 'stephenli.plugin::lang.plugin.categorypick_label'
      type: text
      searchable: true
      sortable: true
  </code></pre>
  
  <p>When I access to my <code>Post</code> Plugin and click the <code>Create</code> button or try to amend any existing record in <code>list</code>, the following error shows:</p>
  
  <blockquote>
    <p>Model 'plugin\Models\Post' does not contain a definition for 'category_id'.</p>
  </blockquote>
  
  <h2>Final edit:</h2>
  
  <p>To sum up everything for any other people who encounter the same issue in the future, there are two methods to solve the problem</p>
  
  <p>You can either </p>
  
  <ol>
  <li>Use <code>Dropdown</code> widget and change the options with <a href="https://stackoverflow.com/questions/41392323/octobercms-call-another-plugins-data-in-current-plugins-dropdown">detailed solution here</a> provided by @Mittul At TechnoBrave</li>
  <li>Or directly use <code>Relation</code> widget as provided in the suggested solution by @dragontree</li>
  </ol>