Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #4808
      conkid
      Member

      Hi All,

      Thanks for great plugin. Just learning the ins and outs now and looking to replace a lot of my past plugin toolbox.

      I can’t believe I’m stuck here but if someone could tell me what I’m doing wrong. I want to group these two fields side by side, each taking up 6 columns. I do not want to group them so values return in array, so not with grouping. They keep stacking on top of each other. Everything I’ve read leads me to believe I put two fields next to each other in my code and use ‘position’ => ‘start’ on the 1st and ‘position’ => ‘end’ on the 2nd and that this should wrap them together by length of columns. Perhaps I’m missing something key?

      piklist('field', array(
      'type' => 'select'
      ,'scope' => 'post_meta' // Not used for settings sections
      ,'field' => 'asset_type'
      ,'label' => 'Select Asset Type'
      ,'help' => __('Select the type of Asset being logged...')
      ,'template' => 'post_meta_custom'
      ,'position' => 'start'
      ,'columns' => '6'
      ,'attributes' => array(
        'class' => 'text'
      )
      ,'choices' => array(
      
         'laptop' => 'Laptop'
        ,'docking_station' => 'Docking Station'
        ,'monitor' => 'Monitor'
        ,'headset' => 'Headset'
        ,'office_phone' => 'Office Phone'
        ,'cell_phone' => 'Cell Phone'
        ,'software' => 'Software'
        ,'monitor' => 'Monitor'
        ,'desktop' => 'Desktop'
        ,'monitor' => 'Monitor'
        ,'ram' => 'Ram'
        ,'hard_drive' => 'Hard Drive'
        ,'battery' => 'Battery'
        ,'laptop_charger' => 'Laptop Charger'
      )
      ));
      
      piklist('field', array(
      'type' => 'select'
      ,'scope' => 'post_meta' // Not used for settings sections
      ,'field' => 'manufacturer'
      ,'label' => 'Select Manufacturer'
      ,'help' => __('Select the manufacturer of Asset being logged...')
      ,'template' => 'post_meta_custom'
      ,'position' => 'end'
      ,'columns' => '6'
      ,'attributes' => array(
        'class' => 'text'
      )
      ,'choices' => array(
      
         'hp' => 'HP'
        ,'lenovo' => 'Lenovo'
        ,'monitor' => 'Monitor'
        ,'headset' => 'Headset'
        ,'office_phone' => 'Office Phone'
        ,'cell_phone' => 'Cell Phone'
        ,'software' => 'Software'
        ,'monitor' => 'Monitor'
        ,'desktop' => 'Desktop'
        ,'monitor' => 'Monitor'
        ,'ram' => 'Ram'
        ,'hard_drive' => 'Hard Drive'
        ,'battery' => 'Battery'
        ,'laptop_charger' => 'Laptop Charger'
      )
      ));
      
    • #4809
      Steve
      Keymaster

      @conkid– Welcome to the Piklist community!

      When you use a group field, the data can be save in an array, OR as separate values. If you use a field name at the group level, like you did with asset_type, the data will be in an array. If you remove that, and just use field names for each field then it won’t.

      Try this updated code. It places two select fields side-by-side, 6 columns each (Piklist uses a 12 column grid).

      piklist('field', array(
        'type' => 'group'
        ,'label' => 'Select Asset Type'
        ,'help' => __('Select the type of Asset being logged...')
        ,'fields' => array(
          array(
            'type' => 'select'
            ,'field' => 'asset_type'
            ,'label' => 'Select Asset'
            ,'columns' => 6
            ,'choices' => array(
               'laptop' => 'Laptop'
              ,'docking_station' => 'Docking Station'
              ,'monitor' => 'Monitor'
              ,'headset' => 'Headset'
              ,'office_phone' => 'Office Phone'
              ,'cell_phone' => 'Cell Phone'
              ,'software' => 'Software'
              ,'monitor' => 'Monitor'
              ,'desktop' => 'Desktop'
              ,'monitor' => 'Monitor'
              ,'ram' => 'Ram'
              ,'hard_drive' => 'Hard Drive'
              ,'battery' => 'Battery'
              ,'laptop_charger' => 'Laptop Charger'
            )
          )
          ,array(
            'type' => 'select'
            ,'field' => 'manufacturer'
            ,'label' => 'Select Manufacturer'
            ,'columns' => 6
            ,'help' => __('Select the manufacturer of Asset being logged...')
            ,'choices' => array(
              'hp' => 'HP'
              ,'lenovo' => 'Lenovo'
              ,'monitor' => 'Monitor'
              ,'headset' => 'Headset'
              ,'office_phone' => 'Office Phone'
              ,'cell_phone' => 'Cell Phone'
              ,'software' => 'Software'
              ,'monitor' => 'Monitor'
              ,'desktop' => 'Desktop'
              ,'monitor' => 'Monitor'
              ,'ram' => 'Ram'
              ,'hard_drive' => 'Hard Drive'
              ,'battery' => 'Battery'
              ,'laptop_charger' => 'Laptop Charger'
            )
          )
        )
      ));
      

      Let me know if this is what you’re looking for.

      Attachments:
      You must be logged in to view attached files.
    • #4918
      conkid
      Member

      Steve – this is just what I needed. Sorry for my late reply. I’m back in it now and digging it, next question coming soon 🙂

    • #4922
      Steve
      Keymaster

      Great. Closing ticket. Let us know if you need more help.

Viewing 3 reply threads
  • The topic ‘Grouping Fields – Noob Question’ is closed to new replies.