Tagged: ,

Viewing 2 reply threads
  • Author
    Posts
    • #4770
      mcmaster
      Member

      Not sure whether I should be doing something different with my fields? Here is the code:

      piklist( 'field', array(
      	'type' => 'group',
      	'field' => 'home_news',
      	'label' => 'Featured News',
      	'description' => 'Information for the home page news feature.',
      	'template' => 'field',
      	'columns' => 12,
      	'fields' => array(
      		array(
      			'type' => 'text',
      			'field' => 'section_title',
      			'columns' => 8,
      			'label' => 'News Section Title',
      			'value' => "What's New",
      		),
      		array(
      			'type' => 'number',
      			'field' => 'section_quantity',
      			'label' => 'Number of Posts',
      			'description' => 'How many recent posts should we display?',
      			'value' => 2,
      			'validate' => array(
      				array(
      					'type' => 'range',
      					'options' => array(
      						'min' => 1,
      						'max' => 4,
      					),
      				),
      			),
      		),
      		array(
      			'type' => 'text',
      			'field' => 'section_link_text',
      			'label' => 'Text for Link to News Page',
      			'value' => 'View All News',
      			'columns' => 8,
      			'validate' => array(
      				array(
      					'type' => 'safe_text',
      				),
      			),
      		),
      	),
      ));
      

      And attached is an image of the resulting metabox.

      Attachments:
      You must be logged in to view attached files.
    • #4772
      mcmaster
      Member

      I tried removing the line:

      	'template' => 'field',
      

      from the group definition, and the results were not better. 😉

      Again, if I’m being clumsy with my field definitions, please let me know!

      Thanks,
      Donna

      Attachments:
      You must be logged in to view attached files.
    • #4781
      Steve
      Keymaster

      Piklist uses a 12 column grid. So each row of fields should equal 12. Try this:

      piklist( 'field', array(
        'type' => 'group',
        'field' => 'home_news',
        'label' => 'Featured News',
        'description' => 'Information for the home page news feature.',
        'template' => 'field',
        'fields' => array(
          array(
            'type' => 'text',
            'field' => 'section_title',
            'columns' => 8, // First row: 8 columns
            'label' => 'News Section Title',
            'value' => "What's New",
          ),
          array(
            'type' => 'number',
            'field' => 'section_quantity',
            'label' => 'Number of Posts',
            'description' => 'How many recent posts should we display?',
            'columns' => 4, // First row: 4 columns. Row will end here because 12 columns have been reached.
            'value' => 2,
            'validate' => array(
              array(
                'type' => 'range',
                'options' => array(
                  'min' => 1,
                  'max' => 4,
                ),
              ),
            ),
          ),
          array(
            'type' => 'text',
            'field' => 'section_link_text',
            'label' => 'Text for Link to News Page',
            'value' => 'View All News',
            'columns' => 12, // Second row starts here
            'validate' => array(
              array(
                'type' => 'safe_text',
              ),
            ),
          ),
        ),
      ));
      
Viewing 2 reply threads
  • The topic ‘label misplaced in add-more (0.9.9.4)’ is closed to new replies.