Giter Club home page Giter Club logo

Comments (5)

patrickyan avatar patrickyan commented on July 28, 2024

To be clear both image entries are created, but only the first id gets passed through to the hidden input.

from sections_event.

vlad-ghita avatar vlad-ghita commented on July 28, 2024

Given this HTML

<input name="images[]" value="v1,v2,v3"/>

in PHP you will get an array called images and the element with first index 0 will contain the data:

$_POST['images'][0] === 'v1,v2,v3'

Given this data, SBL field will store only v1. (see this line)

Given you want to link multiple entries, you have to pass them as elements of the array:

$_POST['images'][0] ==== 'v1'
$_POST['images'][1] ==== 'v2'
$_POST['images'][2] ==== 'v3'

So in HTML you will need something like this:

<input name="images[]" value="v1"/>
<input name="images[]" value="v2"/>
<input name="images[]" value="v3"/>

Applied to your example, you will need

<input name="sections[listings][images][]" type="hidden" value="%images[0][system:id]%"/>
<input name="sections[listings][images][]" type="hidden" value="%images[1][system:id]%"/>

=> in PHP

$_POST[listings][images][0] === %images[0][system:id]%
$_POST[listings][images][1] === %images[1][system:id]%

from sections_event.

patrickyan avatar patrickyan commented on July 28, 2024

Sorry, I posted the wrong code. I'm actually using:

<input name="sections[images][0][image]" id="sections_images_0_image" type="file">
<input name="sections[images][1][image]" id="sections_images_1_image" type="file">
<input name="sections[listings][images]" id="sections_listings_images" type="hidden" value="%images[0][system:id]%,%images[1][system:id]%">

I'm not trying to pass an array for multiple listings entries. I am creating one listings entry with many images. Basically it should be the same as the Readme's Example 4 (books and authors):

My SBL has multiple selection enabled, so it should receive the IDs of both image entries, but something is not going through.

from sections_event.

patrickyan avatar patrickyan commented on July 28, 2024

Ah ok, I got it. So the behavior of SBL for multiple selections is to pass an array, not a comma separated list.

I got confused by Example 4. Assuming Example 4 is passing the IDs to a SBL and not a text field, then shouldn't it also be passing an array of values?

from sections_event.

vlad-ghita avatar vlad-ghita commented on July 28, 2024

So the behavior of SBL for multiple selections is to pass an array, not a comma separated list.

Yep.

I got confused by Example 4. Assuming Example 4 is passing the IDs to a SBL and not a text field, then shouldn't it also be passing an array of values?

You are right. Thanks. Fixed it in this commit.

from sections_event.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.