Home Forums Front-end Issues Frontend Form with particular fields inside repeater


Frontend Form with particular fields inside repeater

  • Hi,

    I have a frontend acf form with these options :

    $edit_post = array(
    ‘fields’ => array(
    ‘post_id’ => $current_boutique_id,
    ‘post_status’ => ‘publish’,
    ‘form’ => true,
    ‘post_title’ => false,
    ‘return’ => ‘%post_url%’,
    ‘html_submit_button’ => ‘<input type=”submit” class=”button edit-boutique-submit” value=”Enregistrer les modifications” />’,

    If you check in the fields, i have a field ’boutique_products’ which is a repeater field. What i need to know is, if it’s possible to display only certain fields INSIDE that particular repeater field.

    Exemple :

    Field 1
    Field 2 (repeater)
    – sub field 1
    – sub field 2
    – sub field 3
    Field 3

    If i wanted to show only sub 1 and sub 3 inside the field 2 (repeater), how can i do this? except with css. Can i use the php options in any way to do this?

    The thing is, some of those repeater’s field are for admin purpose and others are for user purpose. Both fields are required but only the user should be displayed in this frontend form.

  • There isn’t a safe way to do this on the front end except with CSS or JavaScript. The reason is that if the fields are not there and the person reorders the rows then the order of the fields that are not shown will not match the order of the fields that are shown after updating.

    If you use JavaScript to disable the reordering of the fields you can do this with a PHP filter. This can be done using acf/prepare_field Usage #4: acf/prepare_field/key={$field_key} – filter for a specific field based on its key. Just return false from your filter for the fields that you don’t want shown.

  • Oh in fact, i don’t want to hide a row. I want to hide a column.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Frontend Form with particular fields inside repeater’ is closed to new replies.