Support » Plugin: Block Lab » Suggestion – Autocomplete fields

  • Resolved Martin Taylor

    (@docdunning)


    Hi

    I’ve recently started trying out Block Lab and am finding it *really* useful. I can see a number of situations where it will come in very handy.

    A suggestion (and/or question): I’d like to have one of the fields in the block act as an autocomplete, so that typing into it generates a call to a PHP routine that pops up some suggestions in the UI. I’ve experience of doing this on other sites, but not in WordPress. Is that possible as the plugin stands now, or is there a way to add the necessary events to the block fields outside the plugin?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @docdunning,
    Thanks a lot for using Block Lab, and for your kind words.

    There isn’t anything that does that so far, but it’s an interesting idea.

    What kind of field would this be? A text field?

    And where would the suggestions be from?

    Thanks, that’s an interesting idea.

    Yes, I guess a text field is the most likely. In the past, I’ve used jQuery’s Autocomplete which can have an inline array of data suggestions, or an Ajax source, which is what I’ve more often done. Type in a few letters and it pops up a dropdown with matching items … I’m sure you know what I mean.

    I tried to add some home-brewed JS to the post editor page, but of course, all of the blocks are added dynamically. That makes it rather more tricky to add the Autocomplete widget to the items. I think it would have to be added to the fields when they are added to the page.

    I see that in your Pro version, there’s a “post” field type, which might have a similar sort of functionality, but I’m only using the free version at the moment.

    Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @docdunning,
    That makes sense. I assume the ‘Select’ field wouldn’t be sufficient, you’ve probably considered that:

    https://getblocklab.com/docs/fields/select/

    I see that in your Pro version, there’s a “post” field type, which might have a similar sort of functionality, but I’m only using the free version at the moment.

    🙂 Sorry, I think I can only mention the free version in this forum.

    No problem, Ryan.

    I’m using the “select” field for situations where there’s only a limited number of options (as in my other post re “get_terms”). In this case there are potentially hundreds of items to pick from, so an autocomplete/suggest would be good.

    I did eventually manage to get an autocomplete working on the WP edit page in a block field, but the field only remembers the keystrokes I made, not the selection from the autocomplete dropdown (despite several attempts to trigger the change).

    Oh well, I’ll just have to use a straight text box and put some validation on it in the preview template.

    Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @docdunning,
    Thanks for describing your use case. That makes sense, I’ll keep that in mind as we keep adding features.

    If we do add something like that, I’ll ping you on this topic.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.