Viewing 3 reply threads
  • Author
    Posts
    • #8035
      kcarwile
      Participant

      I’ve attached an example of a group field with add_more TRUE. I’m running the latest version of Piklist. With the example, if you add two items to the group, then save the page, and then try to remove 1 of the items, you can’t. It remains as two items but with a duplicate of the first.

    • #8036
      kcarwile
      Participant

      Ok, here is the file in text format.

    • #8037
      kcarwile
      Participant

      My god.

      <?php
      /*
      Title: Test
      Post Type: page
      */
      
      piklist( 'field', array(
      	'type'      => 'group',
      	'field'     => 'rate_options',
      	'label'     => 'Option Prices',
      	'value'     => isset( $rate ) ? $rate->data : array(),
      	'add_more'  => true,
      	'fields'    => array(
      		array(
      			'type'       => 'text',
      			'field'      => 'option_name',
      			'label'      => 'Name',
      			'required'   => true,
      			'sanitize'   => array( array( 'type' => 'text_field' ) ),
      			'attributes' => array(
      				'placeholder' => 'Option Name',
      			),
      		),
      		array(
      			'type'     => 'select',
      			'field'    => 'option_type',
      			'label'    => 'Price Increase',
      			'choices'  => array(
      				1 => 'By Units',
      				2 => 'Fixed',
      				3 => 'Multiplier',
      			),
      		),
      		array(
      			'type'       => 'number',
      			'field'      => 'option_rate',
      			'label'      => 'Rate',
      			'attributes' => array(
      				'placeholder' => 'Rate',
      				'step' => '0.01',
      				'min' => '0',
      				'style' => 'max-width: 100px',
      			),
      		),
      		array( 
      			'type'  => 'number',
      			'field' => 'option_unit_size',
      			'label' => 'Rate Units',
      			'conditions' => array(
      				array(
      					'field' => 'rate_options:option_type',
      					'value' => '1',
      				),
      			),
      			'attributes' => array(
      				'style' => 'max-width: 100px',
      			),
      		),
      		array( 
      			'type'  => 'number',
      			'field' => 'option_min_cost',
      			'label' => 'Minimum Cost',
      			'attributes' => array(
      				'step' => '0.01',
      				'min'  => '0',
      				'style' => 'max-width: 100px',
      			),
      			'conditions' => array(
      				array(
      					'field' => 'rate_options:option_type',
      					'value' => '1',
      				),
      			),
      		),
      		array( 
      			'type'  => 'number',
      			'field' => 'option_max_height',
      			'label' => 'Maximum Height',
      			'conditions' => array(
      				array(
      					'field' => 'rate_options:option_type',
      					'value' => '1',
      				),
      			),
      			'attributes' => array(
      				'style' => 'max-width: 100px',
      			),
      		),
      		array( 
      			'type'  => 'number',
      			'field' => 'option_max_width',
      			'label' => 'Maximum Width',
      			'conditions' => array(
      				array(
      					'field' => 'rate_options:option_type',
      					'value' => '1',
      				),
      			),
      			'attributes' => array(
      				'style' => 'max-width: 100px',
      			),
      		),
      	),
      ) );
    • #8038
      kcarwile
      Participant

      I submitted a pull request with the fix for this bug.

      https://github.com/piklist/piklist/pull/6

Viewing 3 reply threads
  • You must be logged in to reply to this topic.