This topic contains 3 replies, has 2 voices, and was last updated by  Steve 4 months, 4 weeks ago.

  • Author
    Posts
  • #9377

    osmansufy
    Participant

    Hi
    I want to crate repeater field in widgets .Although create it but when save the widgets it save one field only and i can’t work with ‘forech’ loop .
    my widget-form code is hare……

    <?php

    piklist(‘field’, array(
    ‘type’ => ‘group’
    , ‘field’ => ‘social_group’ // removing this parameter saves all fields as separate meta
    , ‘label’ => __(‘Social item’, ‘VerumSocial’)
    , ‘list’ => false
    , ‘description’ => __(‘A grouped field with the field parameter set.’, ‘VerumSocial’)
    , ‘add_more’ => true

    , ‘fields’ => array(
    array(
    ‘type’ => ‘text’
    , ‘field’ => ‘social_icon’
    , ‘label’ => __(‘social_icon’, ‘VerumSocial’)
    , ‘required’ => true
    , ‘columns’ => 12
    , ‘attributes’ => array(
    ‘placeholder’ => ‘social_icon’,
    ),

    )
    , array(
    ‘type’ => ‘url’
    , ‘field’ => ‘social_link’
    , ‘label’ => __(‘Add social link’, ‘VerumSocial’)
    , ‘columns’ => 12
    , ‘attributes’ => array(
    ‘placeholder’ => ‘social link.’,
    ),
    )
    ,
    ),
    ));

    and my widget code is hare
    <?php
    /*
    Title: My Demo Widget
    Description: A description of what my widget does
    */

    echo $before_widget;
    $vsocial = $settings[‘social_group’];

    print_r($vsocial);

    foreach ($vsocial as $vsocial) {

    ?>

    “><i class=”fa fa-<?php echo $vsocial[0][‘social_icon’] ?>”></i>
    <?php

    echo $after_widget;
    }
    ….

    output in front

    Array ( [0] => Array ( [social_icon] => facebook [social_link] => https://www.facebook.com/ ) )

    Attachments:
    You must be logged in to view attached files.
  • #9381

    Steve
    Keymaster

    Does the Piklist Demos repeater work as expected?

  • #9387

    osmansufy
    Participant

    Sorry for late sir . After a lots of time it’s works but when i change the field name(demo field) it dosn’t work . why sir? how to fix these bug ?

  • #9392

    Steve
    Keymaster

    so, $vsocial = $settings[‘social_group’]; is not returning any data?

You must be logged in to reply to this topic.