Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #7532
      norboo
      Member

      Hey guys!

      I have several custom fields for a CPT product:

      piklist('field', array(
          'type' => 'text'
          ,'field' => 'clothes_width'
          ,'label' => __('Width')
          ,'value' => 'N/A'
          ,'attributes' => array(
            'class' => 'text'
          )
      ));

      It’s pretty easy to get the value for each field but I’d like to output it in the following format:

      $clothes_width['label'] => $clothes_width['value']
      eg: Width => N/A
      

      Any idea how to output the label?

    • #7533
      Jason
      Keymaster

      Hi @norboo!

      The label isn’t stored in any way, it’s simply there to help the user when filling out fields. If you really want something like that, then you can use a group field with either a hidden or settable label field:

      piklist('field', array(
        'type'    => 'group',
        'field'   => 'clothes_width',
        'label'   => 'Width',
        'fields'  => array(
          array(
            'type'      => 'text',
            'field'     => 'value',
            'columns'   => 12,
            'value'     => 'N/A',
            'attributes'=> array(
              'class'     => 'text'
            )
          ),
          array(
            'type'    => 'hidden',
            'field'   => 'label',
            'value'   => 'Width'
          )
        )
      ));

      Hope this helps!

Viewing 1 reply thread
  • You must be logged in to reply to this topic.